Week 3 Discussion Forum

What is Linear Search, Brute Force Techniques, Insertion Sort?

What is Linear Search, Brute Force Techniques, Insertion Sort?

by Mafia Islam Sinthia 192-15-2815 -
Number of replies: 1

Linear Search: 

In computer science, a linear search or sequential search is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched.

Brute Force Techniques: 

In computer science, brute-force search or exhaustive search, also known as generate and test, is a very general problem-solving technique and algorithmic paradigm that consists of systematically enumerating all possible candidates for the solution and checking whether each candidate satisfies the problem's statement.

Insertion Sort: 
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.


128 words

In reply to Mafia Islam Sinthia 192-15-2815

Re: What is Linear Search, Brute Force Techniques, Insertion Sort?

by Md. Sabbir Hossain 192-15-2809 -
-Linear Search Algorithm কিভাবে লিখব?
Step-1: Start
Step-2: i = 0, searchItem = 4
Step-3: if i >= n Go to Step-8
Step-4: if a[i] == searchItem go to Step-7
Step-5: i++
Step-6: Go to Step-3
Step-7: print 'item found at index i' and go to Step-9
Step-8: print 'item not found' and go to Step-9
Step-9: Stop

-Linear Search কি?
উত্তরঃ একটি Array বা List থেকে আইটেম খুজে বের করার পদ্ধতি।

-Runtime Complexity?
উত্তরঃ যদি array তে N টা আইটেম থাকে,তাহলে N টা ঘরে গিয়ে গিয়ে আমাদের সার্চ করতে হবে।সহজ কথায় একটা লুপ N বার ঘুরবে আর আইটেম টা সার্চ করবে।তাই এই Algorithm এর টাইম কমপ্লেক্সিটি হবে O(N).

-Space Complexity?
উত্তরঃ যে array আসছে, সেটাতেই কাজ করেছি।কোন অতিরিক্ত যায়গা নেই নি।তাই স্পেস কমপ্লেক্সিটি হবে O(1).

182 words