What is a Linked List? What is searching? Explain Binary Search.

Updated: 2 months ago
উত্তরঃ

1. Linked List

A Linked List is a dynamic linear data structure in which elements are not stored at contiguous memory locations. Instead, elements are linked using pointers.

Each element in a linked list is called a Node, which consists of two main parts:

        
  • Data: Stores the actual value or information.
  •     
  • Next Pointer: Stores the memory address of the next node in the sequence.

Types of Linked List:

        
  • Singly Linked List: Navigation is forward only; each node points to the next node, and the last node points to NULL.
  •     
  • Doubly Linked List: Each node contains two pointers, pointing to both the next and the previous nodes.
  •     
  • Circular Linked List: The last node points back to the first node, forming a circular loop.

2. Searching

Searching is the process of finding the position of a specific target element (or key) within a collection of data structures (such as an array, linked list, or tree).

It is a fundamental operation in computer computer science that returns either the index/location of the requested element or a signal (e.g., -1 or NULL) indicating that the element does not exist in the dataset.


3. Binary Search

Binary Search is an efficient algorithm used to find the position of a target element within a sorted dataset (array or list). It works based on the Divide and Conquer algorithmic paradigm.

Prerequisite: The data elements must be strictly sorted in ascending or descending order.

Working Mechanism / Algorithm:

        
  1. Set two pointers, \(\text{low}\) at the first index (\(0\)) and \(\text{high}\) at the last index (\(n-1\)).
  2.     
  3. Calculate the middle index: \(\text{mid} = \lfloor \frac{\text{low} + \text{high}}{2} \rfloor\).
  4.     
  5. Compare the target element with the middle element (\(\text{Array}[\text{mid}]\)):         
                  
    • If \(\text{Target} == \text{Array}[\text{mid}]\), the element is found; return \(\text{mid}\).
    •             
    • If \(\text{Target} < \text{Array}[\text{mid}]\), search the left half by setting \(\text{high} = \text{mid} - 1\).
    •             
    • If \(\text{Target} > \text{Array}[\text{mid}]\), search the right half by setting \(\text{low} = \text{mid} + 1\).
    •         
        
  6.     
  7. Repeat steps 2 and 3 until the element is found or \(\text{low} > \text{high}\) (target not present).

Example Demonstration:

Given sorted array: \([10, 20, 30, 40, 50, 60, 70]\) and \(\text{Target} = 50\)

        
  • Pass 1: \(\text{low} = 0\), \(\text{high} = 6\) \(\rightarrow\) \(\text{mid} = \lfloor \frac{0+6}{2} \rfloor = 3\). \(\text{Array}[3] = 40\). Since \(50 > 40\), search shifts right: \(\text{low} = 3 + 1 = 4\).
  •     
  • Pass 2: \(\text{low} = 4\), \(\text{high} = 6\) \(\rightarrow\) \(\text{mid} = \lfloor \frac{4+6}{2} \rfloor = 5\). \(\text{Array}[5] = 60\). Since \(50 < 60\), search shifts left: \(\text{high} = 5 - 1 = 4\).
  •     
  • Pass 3: \(\text{low} = 4\), \(\text{high} = 4\) \(\rightarrow\) \(\text{mid} = \lfloor \frac{4+4}{2} \rfloor = 4\). \(\text{Array}[4] = 50\). Target matched at index \(4\).

Complexity Analysis:

        
  • Best-case Time Complexity: \(O(1)\) (When the element is at the mid position on the first check)
  •     
  • Average & Worst-case Time Complexity: \(O(\log_2 n)\)
  •     
  • Auxiliary Space Complexity: \(O(1)\) (Iterative implementation)
Satt AI
Satt AI
2 weeks ago
34

Related Question

View All
উত্তরঃ

কম্পিউটারের মেমরি (Memory) ব্যবস্থায় RAM (Random Access Memory) এবং ROM (Read Only Memory) উভয়ই গুরুত্বপূর্ণ ভূমিকা পালন করে। এদের মৌলিক প্রকৃতি ও কার্যকারিতার মধ্যে বেশ কিছু সুস্পষ্ট পার্থক্য বিদ্যমান, যা নিচে একটি সারণীর মাধ্যমে ব্যাখ্যা করা হলো:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
বৈশিষ্ট্য (Feature)RAM (র‍্যাম)ROM (রম)
পুরো নাম (Full Name)Random Access MemoryRead Only Memory
প্রকৃতি (Nature)এটি একটি Volatile (উদ্বায়ী) মেমরি।এটি একটি Non-volatile (অনুদ্বায়ী) মেমরি।
ডেটা সংরক্ষণ (Data Storage)অস্থায়ীভাবে ডেটা সংরক্ষণ করে। কম্পিউটার চালু থাকাকালীন ডেটা ও প্রোগ্রাম লোড করে।স্থায়ীভাবে ডেটা সংরক্ষণ করে। গুরুত্বপূর্ণ সিস্টেম ফাইল ও ফার্মওয়্যার (Firmware) থাকে।
ডেটা পরিবর্তন (Data Modification)ডেটা পড়া (Read) এবং লেখা (Write) উভয়ই করা যায়, অর্থাৎ ডেটা পরিবর্তনযোগ্য।সাধারণত শুধু ডেটা পড়া যায়; ডেটা লেখা বা পরিবর্তন করা কঠিন বা বিশেষ পদ্ধতির প্রয়োজন।
গতি (Speed)ROM-এর চেয়ে অনেক দ্রুত কাজ করে।RAM-এর চেয়ে ধীর গতিসম্পন্ন।
বিদ্যুৎ চলে গেলে (Power Off)বিদ্যুৎ সরবরাহ বন্ধ হলে এতে সংরক্ষিত সমস্ত ডেটা হারিয়ে যায়।বিদ্যুৎ সরবরাহ বন্ধ হলেও এতে সংরক্ষিত ডেটা অক্ষত থাকে।
ব্যবহার (Usage)অপারেটিং সিস্টেম (Operating System), অ্যাপ্লিকেশন প্রোগ্রাম (Application Program) এবং বর্তমান কাজের ডেটা লোড করার জন্য ব্যবহৃত হয়।কম্পিউটার চালু করার জন্য প্রয়োজনীয় বুটস্ট্র্যাপ নির্দেশাবলী (Bootstrap Instructions) এবং বায়োস (BIOS) বা ইউইএফআই (UEFI) ফার্মওয়্যার সংরক্ষণ করে।
ক্ষমতা (Capacity)সাধারণত GB (গিগাবাইট)-এর এককে পরিমাপ করা হয় (যেমন: 4GB, 8GB, 16GB)।সাধারণত MB (মেগাবাইট)-এর এককে পরিমাপ করা হয় (যেমন: 4MB, 8MB, 16MB)।
উদাহরণ (Examples)DRAM (Dynamic RAM), SRAM (Static RAM)।PROM (Programmable ROM), EPROM (Erasable PROM), EEPROM (Electrically Erasable PROM)।

সংক্ষেপে, RAM একটি দ্রুত, অস্থায়ী কার্যকারী মেমরি যা কম্পিউটারকে বর্তমান কাজগুলো সম্পাদন করতে সাহায্য করে, অন্যদিকে ROM একটি ধীর, স্থায়ী মেমরি যা কম্পিউটার চালু করার জন্য অপরিহার্য মৌলিক নির্দেশাবলী সংরক্ষণ করে।

Satt AI
Satt AI
1 month ago
341
শিক্ষকদের জন্য বিশেষভাবে তৈরি

১ ক্লিকে প্রশ্ন, শীট, সাজেশন
অনলাইন পরীক্ষা তৈরির সফটওয়্যার!

শুধু প্রশ্ন সিলেক্ট করুন — প্রশ্নপত্র অটোমেটিক তৈরি!

প্রশ্ন এডিট করা যাবে
জলছাপ দেয়া যাবে
ঠিকানা যুক্ত করা যাবে
Logo, Motto যুক্ত হবে
অটো প্রতিষ্ঠানের নাম
অটো সময়, পূর্ণমান
প্রশ্ন এডিট করা যাবে
জলছাপ দেয়া যাবে
ঠিকানা যুক্ত করা যাবে
Logo, Motto যুক্ত হবে
অটো প্রতিষ্ঠানের নাম
অটো সময়, পূর্ণমান
অটো নির্দেশনা (এডিটযোগ্য)
অটো বিষয় ও অধ্যায়
OMR সংযুক্ত করা যাবে
ফন্ট, কলাম, ডিভাইডার
প্রশ্ন/অপশন স্টাইল পরিবর্তন
সেট কোড, বিষয় কোড
অটো নির্দেশনা (এডিটযোগ্য)
অটো বিষয় ও অধ্যায়
OMR সংযুক্ত করা যাবে
ফন্ট, কলাম, ডিভাইডার
প্রশ্ন/অপশন স্টাইল পরিবর্তন
সেট কোড, বিষয় কোড
এখনই শুরু করুন ডেমো দেখুন
৫০,০০০+
শিক্ষক
৩০ লক্ষ+
প্রশ্নপত্র
মাত্র ১৫ পয়সায় প্রশ্নপত্র
১ ক্লিকে প্রশ্ন, শীট, সাজেশন তৈরি করুন আজই

Complete Exam
Preparation

Learn, practice, analyse and improve

1M+ downloads
4.6 · 8k+ Reviews