0% found this document useful (0 votes)
20 views3 pages

VL2022230101195 Ast05

The document outlines 3 programming problems: 1) Counting digit occurrences and performing merge sort. 2) Finding even divisible numbers in an array and searching for the second smallest index. 3) Hashing keys using mid-square hashing, handling collisions, and resolving using quadratic probing.

Uploaded by

Om Raj
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)
20 views3 pages

VL2022230101195 Ast05

The document outlines 3 programming problems: 1) Counting digit occurrences and performing merge sort. 2) Finding even divisible numbers in an array and searching for the second smallest index. 3) Hashing keys using mid-square hashing, handling collisions, and resolving using quadratic probing.

Uploaded by

Om Raj
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
You are on page 1/ 3

Fall Semester 2022 - BITE201P - Data

Structures and Algorithms Lab


LAB ASSESSMENT - 3

Total number of question to be solved is 3


Implementation Using C

1. Assume the following sequence of input

7,7,5,2,5,2,8,5,6,8,8,7,4,4,7,2,3,8,9,3,2,9,7,8,3

Count the number of occurrence of each digit (as per


increasing order of given digit) and store those numbers
in a new array. The result of this process looks like
4,3,2,3,1,5,5,2
Means digit 2 occurs 4 times, digit 3 occurs 3 times, digit
4 occurs 2 times, digit 5 occurs 3 times, digit 6 occurs 1
time, digit 7 occurs 5 times, digit 8 occurs 5 times, and
digit 9 occurs 2 times.
Assume this intermediate output sequence as an
input for merge sort and perform merge sort to get
sorted order in both ascending and descending order.
2. Let the input sequence (Must be an unrepeated
sequence, ask the user to re-enter if the sequence is
with repeated values) be
4,3,2,1,5,8
Using this input sequence find the set of numbers which
is divisible by any even number and repeat the till the
end of the given array and move all the obtained
intermediate results into a new array. In this case we got
the following intermediate results for the given
unrepeated input sequence
4,2,8.
(order of this intermediate result is also important,
means the given input sequence must be tracked from
left to right).
Using this intermediate result search for the second
smallest index (assume index ranges from 0 to n-1)
cum number using both linear search and binary
search (also try with a lengthier sequence of valid
input). This gives the final answer as
index is 1 and the corresponding number is
2.
3. Using the mid square hash function method insert the
following keys into the hash table.
Let Size be 1000
Let Keys be 789456123, 122012010

H(Key) = square of Key

Let the folding be with n-1 digits of given size here 4-1
= 3 digit folding.

Display the hash table after inserted with the given all
keys if no collision is found.

If collision is found then display the first inserted value


into the hash table along with a message collision
occurred while trying to insert the second key. Note: In
this case collision is found for the given keys

Further resolve the collision using quadratic probing


and display the resolved results along with the
corresponding hash table values.

You might also like