0% found this document useful (0 votes)
41 views4 pages

Data Structures: Sorting, Searching, Stacks, Queues

The document outlines key concepts in data structures, specifically focusing on sorting, searching, stacks, and queues. It includes definitions, algorithms, and comparisons such as selection sort, bubble sort, and the differences between sequential and binary searches. Additionally, it covers stack and queue operations, including their applications and types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views4 pages

Data Structures: Sorting, Searching, Stacks, Queues

The document outlines key concepts in data structures, specifically focusing on sorting, searching, stacks, and queues. It includes definitions, algorithms, and comparisons such as selection sort, bubble sort, and the differences between sequential and binary searches. Additionally, it covers stack and queue operations, including their applications and types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 02: Data Structures (Units 3 & 4)

Unit 3: Sorting and Searching

Unit 3: Sorting and Searching - 2 Marks Questions

1. Define linear array.

A linear array is a data structure consisting of a collection of elements stored at contiguous memory locations.

2. What is traversing in an array?

Traversing an array means accessing and processing each element sequentially.

3. List any two sorting algorithms.

- Bubble Sort

- Selection Sort

4. What is sequential search?

It is a method to find a value by checking each element sequentially.

5. Difference between iterative and recursive searching.

- Iterative uses loops; recursive calls itself with sub-problems.

Unit 3: Sorting and Searching - 5 Marks Questions

1. Selection Sort with Example:


Assignment 02: Data Structures (Units 3 & 4)

Selection sort selects the smallest element and places it at the start.

Example: [29,10,14,37,13] becomes [10,13,14,29,37].

2. Bubble Sort Algorithm:

Repeat for i = 0 to n-1, and for j = 0 to n-i-2, swap if A[j] > A[j+1].

3. Sequential vs Binary Search:

Sequential checks each element; Binary divides the array. Binary is faster but needs sorted array.

4. Traversing Linear Array:

Start from index 0, access and process each element till the last.

5. Insert into Array Algorithm:

Shift elements right from position, then insert new value.

Unit 3: Sorting and Searching - 10 Marks Questions

1. Quick Sort:

A divide-and-conquer algorithm that selects a pivot and partitions array.

Example: [10,80,30,90] -> Pivot 70 -> Partitions and recursively sorts.

2. Merge Sort:

Divides array, sorts subarrays, and merges. Time: O(n log n).
Assignment 02: Data Structures (Units 3 & 4)

3. Binary Search (Iterative & Recursive):

Both methods locate middle, compare and search halves. Works only on sorted arrays.

4. Delete from Array:

Shift all elements left after the deletion point.

Example: Delete 3rd index from [5,10,15,20] -> [5,10,20].

Unit 4: Stacks and Queues

Unit 4: Stacks and Queues - 2 Marks Questions

1. Define stack.

Stack follows LIFO: Last In First Out.

2. What is a queue?

Queue follows FIFO: First In First Out.

3. Applications of stacks:

- Expression evaluation

- Function call management

4. What is postfix notation?

Operators follow operands, e.g., AB+


Assignment 02: Data Structures (Units 3 & 4)

5. Types of queues:

- Simple Queue

- Circular Queue

- Deque

- Priority Queue

Unit 4: Stacks and Queues - 5 Marks Questions

1. Push and Pop:

Push adds to top, Pop removes from top. Follows LIFO.

2. Infix to Postfix Algorithm:

Use stack for operators, output for operands, and apply precedence rules.

3. Simple Queue Operations:

Enqueue (add), Dequeue (remove), Front (peek), IsEmpty/IsFull.

4. Applications of stacks:

- Recursion tracking

- Expression conversion

5. Circular vs Double-Ended Queue:

Circular queue wraps around; deque allows insert/delete from both ends.

You might also like