ZS Associate DSA Questions and Answers Quiz-1

Question 1

Time: 00:00:00
What is meant by physical size in a dynamic array?

The size allocated to elements

The size allocated to elements

The size extended to add new elements

The size extended to add new elements

The size of the underlying array at the back-end

The size of the underlying array at the back-end

The size visible to users

The size visible to users

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

A

Start

Question 2

Time: 00:00:00
What is the time complexity for inserting/deleting at the beginning of the array?

O(1)

O(1)

O(n)

O(n)

O(logn)

O(logn)

O(nlogn)

O(nlogn)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the functionality of the following code? Choose the most appropriate answer.







public int function()
{
if(head == null)
return Integer.MIN_VALUE;
int var;
Node temp = head;
while(temp.getNext() != head)
temp = temp.getNext();
if(temp == head)
{
var = head.getItem();
head = null;
return var;
}
temp.setNext(head.getNext());
var = head.getItem();
head = head.getNext();
return var;
}







Return data from the end of the list

Return data from the end of the list

Returns the data and deletes the node at the end of the list

Returns the data and deletes the node at the end of the list

Returns the data from the beginning of the list

Returns the data from the beginning of the list

Returns the data and deletes the node from the beginning of the list

Returns the data and deletes the node from the beginning of the list

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the condition for an equivalence relation if two cities are related within a country?

the two cities should have a one-way connection

the two cities should have a one-way connection

the two cities should have a two-way connection

the two cities should have a two-way connection

the two cities should be in different countries

the two cities should be in different countries

no equivalence relation will exist between two cities

no equivalence relation will exist between two cities

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What is the functionality of the following piece of code?







public void fun(int x)
{
q1.offer(x);
}







Perform push() with push as the costlier operation

Perform push() with push as the costlier operation

Perform push() with pop as the costlier operation

Perform push() with pop as the costlier operation

Perform pop() with push as the costlier operation

Perform pop() with push as the costlier operation

Perform pop() with pop as the costlier operation

Perform pop() with pop as the costlier operation

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Making the pop operation costly, select the code snippet which implements the same.
a)







public int pop()
{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>0)
q2.offer(q1.poll());
res = q1.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>0)
q1.offer(q2.poll());
res = q2.poll();
}
return res;
}








b)







public int pop()
{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>1)
q2.offer(q1.poll());
res = q2.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>1)
q1.offer(q2.poll());
res = q1.poll();
}
return res;
}








c)







public int pop()
{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>1)
q2.offer(q1.poll());
res = q1.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>1)
q1.offer(q2.poll());
res = q2.poll();
}
return res;

d) None of the mentioned







a)

a)

b)

b)

c)

c)

d)

d)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
After applying the below operations on a input sequence, what happens?
i. construct a cartesian tree for input sequence
ii. put the root element of above tree in a priority queue
iii. if( priority queue is not empty) then
.search and delete minimum value in priority queue
.add that to output
.add cartesian tree children of above node to priority queue

constructs a cartesian tree

constructs a cartesian tree

sorts the input sequence

sorts the input sequence

does nothing

does nothing

produces some random output

produces some random output

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Which of the following can be called a parallel array implementation?
a)







   firstName  = ['Joe','Bob','Frank','Hans']
lastName = ['Smith','Seger','Sinatra','Schultze']
heightInCM = [169,158,201,199]
 
for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]








b)







   firstName  = ['Joe','Bob','Frank','Hans']
lastName = ['Smith','Seger']
heightInCM = [169,158]
 
for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]








c)







   firstName  = ['Joe','Bob']
lastName = ['Smith','Seger','Sinatra','Schultze']
heightInCM = [169,158]
 
for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]








d) None of the mentioned

a)

a)

b)

b)

c)

c)

d)

d)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Given the code ,choose the correct option that is consistent with the code







	build(A,i)
left-> 2*i
right->2*i +1
temp- > i
if(left<= heap_length[A] ans A[left] >A[temp])
temp -> left
if (right = heap_length[A] and A[right] > A[temp])
temp->right
if temp!= i
swap(A[i],A[temp])
build(A,temp)








Here A is the heap

It is the build function of max heap

It is the build function of max heap

It is the build function of min heap

It is the build function of min heap

It is general build function of any heap

It is general build function of any heap

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
If row-major order is used, how is the following matrix stored in memory?
a b c
d e f
g h i

ihgfedcba

ihgfedcba

abcdefghi

abcdefghi

cfibehadg

cfibehadg

adgbehcfi

adgbehcfi

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects