0% found this document useful (0 votes)
17 views

Data Structure - CS3301 - Important Questions With Answer - Unit 5 - Searching Sorting and Hashing Techniques

Uploaded by

kameshelumalai29
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)
17 views

Data Structure - CS3301 - Important Questions With Answer - Unit 5 - Searching Sorting and Hashing Techniques

Uploaded by

kameshelumalai29
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/ 16

Click on Subject/Paper under Semester to enter.

Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester

4th Semester
- MA3151 MA3251 Computer Organization
1st Semester

2nd Semester

- CS3351 Artificial Intelligence


Engineering Graphics and Machine Learning
Engineering Physics - - CS3491
- GE3251 Foundation of Data
PH3151
Science - CS3352
Database Management
Physics for
Engineering Chemistry System - CS3492
Information Science Data Structure -
- CY3151 - PH3256 CS3301

Basic Electrical and


Algorithms - CS3401
Problem Solving and Electronics Engineering Object Oriented
Python Programming - - BE3251 Programming - CS3391 Introduction to
GE3151 Operating Systems -
Programming in C -
CS3451
CS3251

Computer Networks - Object Oriented


CS3591 Software Engineering
- CCS356
Compiler Design - Human Values and
5th Semester

CS3501 Embedded Systems Ethics - GE3791


7th Semester

8th Semester
6th Semester

and IoT - CS3691


Cryptography and Open Elective 2
Cyber Security - Open Elective-1 Project Work /
CB3491
Open Elective 3 Intership
Distributed Computing Elective-3
- CS3551 Open Elective 4
Elective-4
Elective 1
Management Elective
Elective-5
Elective 2
Elective-6
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to
enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering
www.BrainKart.com Page 1 of 8

4931_Grace College of Engineering, Thoothukudi

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BE- Computer Science and Engineering

E
Anna University Regulation: 2021

CS3301 – DATA STRUCTURES CO


CE

II Year/III Semester
RA

QUESTION BANK (2 Marks & 16 Marks)


G

UNIT -5 (SEARCHING, SORTING AND HASHING

TECHNIQUES)

Prepared By,

Mrs. K.M.ANNAMMAL, AP/CSE

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 2 of 8

4931_Grace College of Engineering, Thoothukudi

TWO MARKS
1. Define sorting
Sorting arranges the numerical and alphabetical data present in a list in a
specific order or sequence. There are a number of sorting techniques
available. The algorithms can be chosen based on the following factors –
Size of the data structure – Algorithm efficiency – Programmer’s knowledge
of the technique.
2. What do you mean by internal and external sorting?
An internal sort is any data sorting process that takes place entirely within the
main memory of a computer. This is possible whenever the data to be sorted
is small enough to all be held in the main memory. External sorting is a term
for a class of sorting algorithms that can handle massive amounts of data.

E
External sorting is required when the data being sorted do not fit into the

CO
main memory of a computing device (usually RAM) and instead they must
reside in the slower external memory (usually a hard drive)
3. Define bubble sort
Bubble sort is a simple sorting algorithm that works by repeatedly stepping
through the list to be sorted, comparing each pair of adjacent items and
swapping them if they are in the wrong order. The pass through the list is
CE
repeated until no swaps are needed, which indicates that the list is sorted. The
algorithm gets its name from the way smaller elements "bubble" to the top of
the list
4. How the insertion sort is done with the array?
RA

It sorts a list of elements by inserting each successive element in the


previously sorted sublist. Consider an array to be sorted A[1],A[2],….A[n] a.
Pass 1 : A[2] is compared with A[1] and placed them in sorted order. b. Pass
2 : A[3] is compared with both A[1] and A[2] and inserted at an appropriate
G

place. This makes A[1], A[2],A[3] as a sorted sub array. c. Pass n-1 : A[n] is
compared with each element in the sub array A[1],A[2],……A[n-1] and
inserted at an appropriate position.
5. What are the steps for selection sort?
 The algorithm divides the input list into two parts: the sublist of items
already sorted, which is built up from left to right at the front (left) of the list,
and the sublist of items remaining to be sorted that occupy the rest of the list.
 Initially, the sorted sublist is empty and the unsorted sublist is the entire
input list.  The algorithm proceeds by finding the smallest (or largest,
depending on sorting order) element in the unsorted sublist, exchanging it
with the leftmost unsorted element (putting it in sorted order), and moving

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 3 of 8

4931_Grace College of Engineering, Thoothukudi

the sublist boundaries one element to the right.


6. What is meant by shell sort?
Shell sort, also known as Shell sort or Shell's method, is an in-place
comparison sort. It can either be seen as a generalization of sorting by
exchange (bubble sort) or sorting by insertion (insertion sort).[1] The method
starts by sorting elements far apart from each other and progressively
reducing the gap between them. Starting with far apart elements can move
some out-of-place elements into position faster than a simple nearest
neighbor exchange. Donald Shell published the first version of this sort in
1959. The running time of Shell sort is heavily dependent on the gap
sequence it uses
7. Define radix sort

E
Radix Sort is a clever and intuitive little sorting algorithm. Radix sort is a
noncomparative integer sorting algorithm that sorts data with integer keys by

CO
grouping keys by the individual digits which share the same significant position
and value. Radix Sort puts the elements in order by comparing the digits of the
numbers.

8. What are the advantages of insertion sort


CE
Advantages a. Simplest sorting technique and easy to implement b. It performs
well in the case of smaller lists. c. It leverages the presence of any existing sort
pattern in the list Disadvantages  Efficiency of O(n ) is not well suited for large
RA

sized lists  It requires large number of elements to be shifted

9. Define searching
G

Searching refers to determining whether an element is present in a given list of


elements or not. If the element is present, the search is considered as successful,
otherwise it is considered as an unsuccessful search. The choice of a searching
technique is based on the following factors a. Order of elements in the list i.e.,
random or sorted b. Size of the list

10. Mention the types of searching

The types are  Linear search  Binary search

11. What is meant by linear search?

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 4 of 8

4931_Grace College of Engineering, Thoothukudi

Linear search or sequential search is a method for finding a particular value in a


list that consists of checking every one of its elements, one at a time and in
sequence, until the desired one is found.

12. What is binary search?

For binary search, the array should be arranged in ascending or descending order.
In each step, the algorithm compares the search key value with the middle element
of the array. If the key match, then a matching element has been found and its
index, or position, is returned. Otherwise, if the search key is less than the middle
element, then the algorithm repeats its action on the sub-array to the left of the
middle element or, if the search key is greater, on the sub-array to the right.

E
13. Define hashing function

CO
A hashing function is a key-to-transformation, which acts upon a given key to
compute the relative position of the key in an array. A simple hash function
HASH(KEY_Value)= (KEY_Value)mod(Table-size)

14. What is open addressing?


CE
Open addressing is also called closed hashing, which is an alternative to resolve
the collisions with linked lists. In this hashing system, if a collision occurs,
alternative cells are tired until an empty cell is found.
RA

There are three strategies in open addressing:  Linear probing  Quadratic probing
 Double hashing
G

15. What are the collision resolution methods?

The following are the collision resolution methods  Separate chaining  Open
addressing  Multiple hashing

16. Define separate chaining

It is an open hashing technique. A pointer field is added to each record location,


when an overflow occurs, this pointer is set to point to overflow blocks making a
linked list. In this method, the table can never overflow, since the linked lists are
only extended upon the arrival of new keys

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 5 of 8

4931_Grace College of Engineering, Thoothukudi

17 . Define Hashing.

Hashing is the transformation of string of characters into a usually shorter fixed


length value or key that represents the original string. Hashing is used to index and
retrieve items in a database because it is faster to find the item using the short
hashed key than to find it using the original value.

18. What do you mean by hash table?

The hash table data structure is merely an array of some fixed size, containing the
keys. A key is a string with an associated value. Each key is mapped into some
number in the range 0 to tablesize-1 and placed in the appropriate cell.

E
19.What do you mean by hash function?

CO
A hash function is a key to address transformation which acts upon a given key to
compute the relative position of the key in an array. The choice of hash function
should be simple and it must distribute the data evenly. A simple hash function is
hash_key=key mod tablesize.
CE
20 Write the importance of hashing.

• Maps key with the corresponding value using hash function. • Hash tables
support the efficient addition of new entries and the time spent on searching for the
RA

required data is independent of the number of items stored.

21. What do you mean by collision in hashing?

When an element is inserted, it hashes to the same value as an already inserted


G

element, and then it produces collision.

22. What are the collision resolution methods?

• Separate chaining or External hashing • Open addressing or Closed hashing

23. What do you mean by separate chaining?

Separate chaining is a collision resolution technique to keep the list of all elements
that hash to the same value. This is called separate chaining because each hash
table element is a separate chain (linked list). Each linked list contains all the
elements whose keys hash to the same index.

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 6 of 8

4931_Grace College of Engineering, Thoothukudi

24. Write the advantage of separate chaining.

• More number of elements can be inserted as it uses linked lists.

25.Write the disadvantages of separate chaining.

• The elements are evenly distributed. Some elements may have more elements and
some may not have anything.

• It requires pointers. This leads to slow the algorithm down a bit because of the
time required to allocate new cells, and also essentially requires the
implementation of a second data structures

E
26. What are the types of collision resolution strategies in open addressing?

• Linear probing • Quadratic probing • Double hashing

27. What do you mean by Probing?


CO
Probing is the process of getting next available hash table array cell.

28.What do you mean by linear probing?


CE
Linear probing is an open addressing collision resolution strategy in which F is a
linear function of i, F(i)=i. This amounts to trying sequentially in search of an
RA

empty cell. If the table is big enough, a free cell can always be found, but the time
to do so can get quite large.

29. What do you mean by double hashing?


G

Double hashing is an open addressing collision resolution strategy in which


F(i)=i.hash2(X). This formula says that we apply a second hash function to X and
probe at a distance hash2(X), 2hash2(X),….,and so on. A function such as
hash2(X)=R-(XmodR), with R a prime smaller than

30. What do you mean by rehashing?

If the table gets too full, the running time for the operations will start taking too
long and inserts might fail for open addressing with quadratic resolution. A
solution to this is to build another table that is about twice as big with the
associated new hash function and scan down the entire original hash table,

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 7 of 8

4931_Grace College of Engineering, Thoothukudi

computing the new hash value for each element and inserting it in the new table.
This entire operation is called rehashing.

31. What is the need for extendible hashing?

If either open addressing hashing or separate chaining hashing is used, the major
problem is that collisions could cause several blocks to be examined during a Find,
even for a welldistributed hash table. Extendible hashing allows a find to be
performed in two disk accesses. Insertions also require few disk accesses.

32. List the limitations of linear probing.

• Time taken for finding the next available cell is large. • In linear probing, we

E
come across a problem known as clustering.

CO
33. Mention one advantage and disadvantage of using quadratic probing.
Advantage: The problem of primary clustering is eliminated. Disadvantage: There
is no guarantee of finding an unoccupied cell once the table is nearly half full.
CE
34. Mention the types of sorting

 Internal sorting  External sorting


RA

PART B
1.Outline the algorithm to perform linear search on an array of ‘N’ numbers .
Illustrate each step of the algorithm with an example(Nov/Dec 2022)
2.Outline the algorithm to sort an array of ‘N’ numbers using bubble sort. Illustrate
G

each step of the algorithm with an example? (Nov/Dec 2022)


3.Outline the steps in the insertion sort algorithm and apply the algorithm for the
numbers given below
12,06,14,02,01,04,03 (Nov/Dec 2022)
4.Write an algorithm to implement bubble sort with suitable examples (April/May
2023)
5.Discuss the common collision resolution techniques used in closed hashing
systems (April/May 2023)

6.The keys 12,18,13,2,3,23,5 and 15 are inserted into an initially empty hash table
of length 10 using linear probing with hash function h(k)= k mod 10. What is the

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com Page 8 of 8

4931_Grace College of Engineering, Thoothukudi

resultant hash table. (April/May 2023)

E
CO
CE
RA
G

CS3301_DS

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
Click on Subject/Paper under Semester to enter.
Professional English Discrete Mathematics Environmental Sciences
Professional English - - II - HS3252 - MA3354 and Sustainability -
I - HS3152 GE3451
Digital Principles and
Statistics and Probability and
Computer Organization
Matrices and Calculus Numerical Methods - Statistics - MA3391
- CS3351
- MA3151 MA3251
3rd Semester
1st Semester

4th Semester
2nd Semester

Database Design and Operating Systems -


Engineering Physics - Engineering Graphics
Management - AD3391 AL3452
PH3151 - GE3251

Physics for Design and Analysis of Machine Learning -


Engineering Chemistry Information Science Algorithms - AD3351 AL3451
- CY3151 - PH3256
Data Exploration and Fundamentals of Data
Basic Electrical and
Visualization - AD3301 Science and Analytics
Problem Solving and Electronics Engineering -
BE3251 - AD3491
Python Programming -
GE3151 Artificial Intelligence
Data Structures Computer Networks
- AL3391
Design - AD3251 - CS3591

Deep Learning -
AD3501

Embedded Systems
Data and Information Human Values and
and IoT - CS3691
5th Semester

Security - CW3551 Ethics - GE3791


6th Semester

7th Semester

8th Semester

Open Elective-1
Distributed Computing Open Elective 2
- CS3551 Project Work /
Elective-3
Open Elective 3 Intership
Big Data Analytics - Elective-4
CCS334 Open Elective 4
Elective-5
Elective 1 Management Elective
Elective-6
Elective 2
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering
Click on Subject/Paper under Semester to enter.
Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester

4th Semester
- MA3151 MA3251 Computer Organization
1st Semester

2nd Semester

- CS3351 Artificial Intelligence


Engineering Graphics and Machine Learning
Engineering Physics - - CS3491
- GE3251 Foundation of Data
PH3151
Science - CS3352
Database Management
Physics for
Engineering Chemistry System - CS3492
Information Science Data Structure -
- CY3151 - PH3256 CS3301

Basic Electrical and


Algorithms - CS3401
Problem Solving and Electronics Engineering Object Oriented
Python Programming - - BE3251 Programming - CS3391 Introduction to
GE3151 Operating Systems -
Programming in C -
CS3451
CS3251

Computer Networks - Object Oriented


CS3591 Software Engineering
- CCS356
Compiler Design - Human Values and
5th Semester

CS3501 Embedded Systems Ethics - GE3791


7th Semester

8th Semester
6th Semester

and IoT - CS3691


Cryptography and Open Elective 2
Cyber Security - Open Elective-1 Project Work /
CB3491
Open Elective 3 Intership
Distributed Computing Elective-3
- CS3551 Open Elective 4
Elective-4
Elective 1
Management Elective
Elective-5
Elective 2
Elective-6
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to
enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering
Click on Subject/Paper under Semester to enter.
Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics - GE3451
I - HS3152 MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester

4th Semester
- MA3151 MA3251 Computer Organization
1st Semester

2nd Semester

- CS3351 Artificial Intelligence


Engineering Graphics and Machine Learning
Engineering Physics - - CS3491
- GE3251 Foundation of Data
PH3151
Science - CS3352
Database Management
Physics for
Engineering Chemistry System - CS3492
Information Science Data Structures and
- CY3151 - PH3256 Algorithms - CD3291
Web Essentials -
Basic Electrical and IT3401
Problem Solving and Electronics Engineering - Object Oriented
Python Programming - BE3251 Programming - CS3391 Introduction to
GE3151 Operating Systems -
Programming in C -
CS3451
CS3251

Computer Networks -
CS3591
Object Oriented
Full Stack Web Software Engineering - Human Values and
5th Semester

Development - IT3501 CCS356 Ethics - GE3791


7th Semester

8th Semester
6th Semester

Distributed Computing Open Elective-1 Open Elective 2


- CS3551 Project Work /
Elective-3 Open Elective 3 Intership
Embedded Systems and
IoT - CS3691 Elective-4
Open Elective 4

Elective 1 Elective-5
Management Elective

Elective-6
Elective 2
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering

You might also like