Professional Documents
Culture Documents
Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
Home
Study
Past Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
University of
Sargodha
MSc. 3rd
Term Examination 2019.
Subject: I.T Paper:
Data Structures and Algorithms(CMP: 3112)
Objective Part
Q. No 01: Write short answers of the
following in 2-3 lines each on your answer sheet
i.
Define Structure of node used in
doubly linked list?
ANSWER:
Node of a double link list contains three portions.
First, previous that maintains the link to the previous node.
Second portion is
data element to store data. And last one is next to maintaining link to the
next node.
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 1/6
7/29/2021 Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
xiv. Write the name of sorting algorithm in which a pivot element is selected to sort array.
Home
Study ANSWER:
Past Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
Quick sort
xv. What is special in binary search tree?
ANSWER: The binary search tree satisfies the search order property; that is, for every node X in the tree, the values
of all the keys in the left subtree are smaller than the key in X and the values of all the keys in the right subtree are
larger than the key in X.
xvi. How many references are maintained in a queue?
ANSWER: In a queue each node maintains a single reference with its previous node.
Q.2. (a) Suppose a link list is empty, Write a function to add a node at the start of the list.
ANSWER:
public void addNode(int d)
{
Node newNode = new Node (d);
newNode.next = null;
head.next = newNode;
lastCurrentNode = currentNode;
currentNode= newNode;
size++;
}
(b) Write a code to delete a node from circular Queue.
ANSWER:
public int dequeue( )
{
if( isEmpty( ) )
throw new RuntimeException( “ListQueue dequeue” );
int returnValue = front.data;
front = front.next;
size–;
return returnValue;
}
Q.3. Convert the following Infix expression to postfix form using a stack and show each step used.
((A+B)/(C+D)$(E/F))+(G+H)/K
Reading Character Postfix Stack
( (
( ((
( (((
A A (((
+ A (((+
B AB (((+
) AB+ ((
/ AB+ ((/
( AB+ ((/(
C AB+C ((/(
+ AB+C ((/(+
D AB+CD ((/(+
) AB+CD+ ((/
$ AB+CD+ ((/$
( AB+CD+ ((/$(
E AB+CD+E ((/$(
/ AB+CD+E ((/$(/
F AB+CD+EF ((/$(/
) AB+CD+EF/ ((/$
) AB+CD+EF/$/ (
( AB+CD+EF/$/ ((
G AB+CD+EF/$/G ((
+ AB+CD+EF/$/G ((+
H AB+CD+EF/$/GH ((+
) AB+CD+EF/$/GH+ (
/ AB+CD+EF/$/GH+ (/
K AB+CD+EF/$/GH+K (/
) AB+CD+EF/$/GH+K/
BST:
Pre Order Traversal: 45, 32, 15, 11, 10, 24, 30, 34, 90, 68, 66, 50, 72
In Order Traversal: 10, 11, 15, 24, 30, 32, 34, 45, 50, 66, 68, 72, 90
Post Order Traversal: 10, 11, 30, 24, 15, 34, 32, 5, 66, 72, 68, 90, 45
Q.5. (a) Write down a function to implement insertion sort.
ANSWER:
void insertion_Sort( AnyType [ ] a )
Join our Whatsapp Group { WhatsApp us
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 2/6
7/29/2021 Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
for( int p = 1; p < a.length; p++ )
Home
Study
Past
{Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
AnyType tmp;
int j = p;
while(j >= 1 && tmp.compareTo( a[ j – 1 ] ) < 0) {
tmp = a[ p ];
a[ j ] = a[ j – 1 ];
a[ j ] = tmp;
j–
}
}
(b) write a recursive function to add 10first 10 integers from 1 to 10
int addNumbers() {
int n=10;
if (n != 0)
return n + addNumbers(n – 1);
else
return n;
}
Q.7. Suppose there are 8 keys with numbers 25, 3, 51, 37, 30, 79, 5, 23. There are 10 hash address are available.
Try to accommodate them in available slots using linear probing technique. The Hashing function used is h
(k) = key%9
ANSWER:
Hash function = h(k) = key%9
h(25) = 25%9 = 7
h(3) = 3%9 = 3
h(51) = 51%9 = 6
h(37) = 37%9 = 1
h(30) = 30%9 = 3
h(79) = 79%9 = 7
h(5) = 5%9 = 5
h(23) = 23%9 = 5
37 3 30 5 51 25 79 23
0 1 2 3 4 5 6 7 8 9
Join our Whatsapp Group WhatsApp us
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 3/6
7/29/2021 Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
Home
Study
Past Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
Read More »
Read More »
Read More »
Read More »
Read More »
Read More »
Read More »
Join our Whatsapp Group WhatsApp us
Web Systems and Technologies IT-3548 Solved Past Paper-2018
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 4/6
7/29/2021 Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
July 9, 2019 /// 5 Comments
Home
Study
Past Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
Read More »
Read More »
Read More »
Read More »
Object Oriented Analysis & Design SE- 3311 Solved Past Paper-2017
July 2, 2019 /// 2 Comments
Read More »
Leave a Comment
Search …
Rising Education
YouTube
00:00 05:47
Home
Study
Intermediate
BA. / BSc
Past Papers
MCQs
Video Tutorials
Programming Fundamentals using C++
Programming Problems
Educational New
Blogs
Free Lancing
Technology
Motivation
Archives
November 2020 (42)
October 2020 (136)
September 2020 (42)
August 2020 (14)
Join our Whatsapp Group WhatsApp us
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 5/6
7/29/2021 Data Structures and Algorithms CMP-3112 Solved Past Paper-2019
July 2020 (2)
Home
Study
Past Papers
MCQs
Video Tutorials
Programming Problems
Educational New
Blogs
May 2020 (1)
April 2020 (1)
March 2020 (8)
February 2020 (359)
January 2020 (503)
December 2019 (109)
November 2019 (35)
October 2019 (5)
September 2019 (202)
August 2019 (96)
July 2019 (22)
June 2019 (2)
May 2019 (2)
April 2019 (5)
Recent Posts
Join our Whatsapp Group WhatsApp us
www.risingeducation.com/data-structures-and-algorithms-cmp-3112-solved-past-paper-2019/ 6/6