Course instructor: mam nadiya



Download 143.46 Kb.
Page1/3
Date05.06.2023
Size143.46 Kb.
#61475
  1   2   3
dsa assign
Lab 1




(DSA) DATA STRUCTURE & ALGORITHM



COURSE INSTRUCTOR: MAM NADIYA


[name: Madhu Sudhan]
[ID: BCB-22S-010]
[DEPARTMENT: COMPUTER SCIENCE]
[PROGRAM: CYBER SECURITY(3RD SEMESTER)]
[SMI University Karachi]



Q1# what is the difference between linear and binary search ?
Ans :

LINEAR SEARCH

BINARY SEARCH

An algorithm to find an element in a lsit by sequentially checking the element of the list until finding the matching element.

An algorithm that finds the position of a target value within a sorted array

Also called sequential search

Also called half-interval search and logarithmic search

Time complexity is O(N)

Time complexity is O( log2N)

Best case is to find the element in the fisrt position

Best case is to find the element in the middle position

It is not required to sort the array before searching the element

It is necessary to sort the array before searching the element

Less efficient

More efficient

Less complex

More complex



Download 143.46 Kb.

Share with your friends:
  1   2   3




The database is protected by copyright ©ininet.org 2024
send message

    Main page