Subject: Computer Science
Paper Code: CSCDSC-151T
Semester: 2nd Semester (FYUG)
Exam Name: Even Semester Exam, 2024
A multidimensional array is an array with more than one dimension, often visualized as a grid (2D) or a collection of grids (3D)
. In memory, which is linear, they are represented using either Row-Major Order (elements stored row by row) or Column-Major Order (elements stored column by column).Expression: (A-B)+C
A doubly linked list is a complex type of linked list in which each node contains a pointer to the next node as well as a pointer to the previous node
.Example: Node(Prev, Data, Next). If we have nodes A, B, and C, B's 'prev' points to A and its 'next' points to C.
| Feature | Array | Linked List |
|---|---|---|
| Size | Fixed/Static | Dynamic |
| Memory Allocation | Compile time | Run time |
| Access | Random access (Fast) | Sequential access (Slow) |
A height-balanced tree (such as an AVL tree) is a binary tree in which the height of the left and right subtrees of every node differs by no more than one
.Advantages: Efficient traversal (no stack/recursion needed) and better utilization of null links
.Linear Search: Works on both sorted and unsorted lists; time complexity is O(n)
.Best Case: Minimum time required by an algorithm for a given input size (optimal scenario)
.Hashing is a technique used to uniquely identify a specific object from a group of similar objects using a mathematical formula called a hash function, which maps data of arbitrary size to a fixed-size table
.Stack: A linear data structure that follows the LIFO (Last In First Out) principle
.Algorithms:
Recursion: A process in which a function calls itself directly or indirectly
.Circular Linked List: A linked list where all nodes are connected to form a circle; there is no NULL at the end
.Insertion (at end): Create new node. Set new_node->next = head. Traverse to last node and set last_node->next = new_node.
Deletion (at end): Traverse to second last node. Set second_last->next = head. Delete the last node.
Expression E: [a+(b-c)] * [(d-e)/(f+g-h)]
Traversals:
Pre-order: * + a - b c / - d e - + f g h
Post-order: a b c - + d e - f g + h - / *
(b) BST Construction: 30, 60, 50, 35, 15, 25
Binary_Search(A, n, item):
Set beg = 0, end = n-1
While beg <= end:
mid = (beg + end) / 2
If A[mid] == item: return mid
Else If item < A[mid]: end = mid - 1
Else: beg = mid + 1
Return -1
Steps for 45 in [15, 21, 26, 30, 35, 45, 50, 55]:
Hash Functions: Division method ($h(k) = k \mod m$), Mid-square method, Folding method
.Differences:
Open Addressing: All elements are stored in the hash table itself (Linear Probing, Quadratic Probing).
Closed Addressing (Chaining): Each slot of the hash table contains a link to a list of elements that hash to the same slot.
Strategies: Chaining, Linear Probing, Quadratic Probing, Double Hashing
.Insertion (Size 10) for [72, 27, 36, 24, 63, 81, 92, 101]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| - | 81 | 72 | 63 | 24 | 92 | 36 | 27 | 101 | - |