This document contains a 30 question mid-semester exam for a data structures and algorithms course. The exam covers topics like asymptotic analysis, sorting algorithms, hashing, binary search trees, and recursion. It provides multiple choice questions to test understanding of algorithm time complexities, worst-case inputs, and recursive functions. Students are instructed to attempt all questions in the 2 hour time limit and notify the proctor if any electronic devices other than calculators are used.
I am Charles G. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, The Pennsylvania State University. I have been helping students with their homework for the past 6 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
I am Geoffrey J. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, Arizona State University. I have been helping students with their homework for the past 8 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
I am Duncan V. I am a Digital Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, Ball State University, Indiana. I have been helping students with their homework for the past 8 years. I solve assignments related to Digital Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Digital Signal Processing Assignments.
I am Charles G. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, The Pennsylvania State University. I have been helping students with their homework for the past 6 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
I am Geoffrey J. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, Arizona State University. I have been helping students with their homework for the past 8 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
I am Duncan V. I am a Digital Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, Ball State University, Indiana. I have been helping students with their homework for the past 8 years. I solve assignments related to Digital Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Digital Signal Processing Assignments.
I am Carl D. I am a Digital Signal Processing System Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, DePaul University, Chicago. I have been helping students with their homework for the past 12 years. I solve assignments related to Digital Signal System Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Digital Signal Processing System Assignments.
I am Elijah L. I am an Algorithm Assignment Expert at programminghomeworkhelp.com. I hold a Bachelor’s Degree in Programming, Leeds University, UK. I have been helping students with their homework for the past 6 years. I solve assignments related to Algorithms.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Algorithm assignments.
I am Travis W. I am a Computer Science Assignment Expert at programminghomeworkhelp.com. I hold a Master's in Computer Science, Leeds University. I have been helping students with their homework for the past 9 years. I solve assignments related to Computer Science.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Computer Science assignments.
I am Charles B. I am an Algorithm Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming, Texas University, USA. I have been helping students with their homework for the past 6 years. I solve assignments related to Algorithms.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Algorithm assignments.
I am Lawrence B. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Masters's in Matlab from, Durham University, UK. I have been helping students with their assignments for the past 5 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
This is a detailed review of ACM International Collegiate Programming Contest (ICPC) Northeastern European Regional Contest (NEERC) 2015 Problems. It includes a summary of problem and names of problem authors and detailed runs statistics for each problem. Video of the actual presentation that was recorded during NEERC is here https://www.youtube.com/watch?v=vn7v1MuWXdU (in Russian)
Note: there were only preliminary stats avaialble, because problems review was happening before before the closing ceremony. This published presentation has full stats.
I am Bianca H. I am a Statistics Assignment Expert at statisticsassignmenthelp.com. I hold a Master in Statistics from, the University of Nottingham, UK. I have been helping students with their assignments for the past 7 years. I solve assignments related to Statistics. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
Backtracking is a general algorithm for finding all (or some) solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons each partial candidate c ("backtracks") as soon as it determines that c cannot possibly be completed to a valid solution.
I am Green J. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, University of Oxford, UK. I have been helping students with their assignments for the past 10 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
I am Carl D. I am a Digital Signal Processing System Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, DePaul University, Chicago. I have been helping students with their homework for the past 12 years. I solve assignments related to Digital Signal System Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Digital Signal Processing System Assignments.
I am Elijah L. I am an Algorithm Assignment Expert at programminghomeworkhelp.com. I hold a Bachelor’s Degree in Programming, Leeds University, UK. I have been helping students with their homework for the past 6 years. I solve assignments related to Algorithms.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Algorithm assignments.
I am Travis W. I am a Computer Science Assignment Expert at programminghomeworkhelp.com. I hold a Master's in Computer Science, Leeds University. I have been helping students with their homework for the past 9 years. I solve assignments related to Computer Science.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Computer Science assignments.
I am Charles B. I am an Algorithm Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming, Texas University, USA. I have been helping students with their homework for the past 6 years. I solve assignments related to Algorithms.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Algorithm assignments.
I am Lawrence B. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Masters's in Matlab from, Durham University, UK. I have been helping students with their assignments for the past 5 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
This is a detailed review of ACM International Collegiate Programming Contest (ICPC) Northeastern European Regional Contest (NEERC) 2015 Problems. It includes a summary of problem and names of problem authors and detailed runs statistics for each problem. Video of the actual presentation that was recorded during NEERC is here https://www.youtube.com/watch?v=vn7v1MuWXdU (in Russian)
Note: there were only preliminary stats avaialble, because problems review was happening before before the closing ceremony. This published presentation has full stats.
I am Bianca H. I am a Statistics Assignment Expert at statisticsassignmenthelp.com. I hold a Master in Statistics from, the University of Nottingham, UK. I have been helping students with their assignments for the past 7 years. I solve assignments related to Statistics. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
Backtracking is a general algorithm for finding all (or some) solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons each partial candidate c ("backtracks") as soon as it determines that c cannot possibly be completed to a valid solution.
I am Green J. I am a Signal Processing Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. in Matlab, University of Oxford, UK. I have been helping students with their assignments for the past 10 years. I solve assignments related to Signal Processing.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com. You can also call on +1 678 648 4277 for any assistance with Signal Processing Assignments.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
1. EE693 DATA STRUCTURES AND ALGORITHMS
MID-SEMESTER EXAMINATION
22 SEPTEMBER, 2014, Time: 2 Hours
EEE Department, IIT Guwahati
NOTE: Attempt and solve all the questions. Question-1 to Question-30 are multiple choice questions (more than one
choices may be correct). Question-1 to Question-30, marks will be awarded, if and only if, all the correct
choice(s) will be made. Use of any kind of electronic media other than calculators are strictly prohibited. If
anybody finds voiding this rule will be penalized with -10 marks penalty. Please do not forget to mention your
Name and Roll No in the paper sheet. Please tick the correct choice(s). All the questions are of 1
mark.
Name: Roll No:
1. This is the welcome question! All the best for EE693 Mid-Semester Examination.
Out of all the 2-digit integers between 1 and 100, a 2-digit number has to be selected at random. What is the
probability that the selected number is not divisible by 7?
(a) 13/90 (b) 12/90 (c) 78/90 (d) 77/90
2. Consider the following function
int unknown( int n)
{
int i , j , k = 0;
for ( i=n /2; i<=n ; i++)
for ( j =2; j<=n ; j=j ∗2)
k=k+n /2;
return k ;
}
The return value of the function is
(a) Θ(n2
) (b) Θ(n2
log n) (c) Θ(n3
) (d) Θ(n3
log n)
3. Let g(n) and f(n) denote respectively, the worst case and average case running time of an algorithm executed on an
input of size n. Which of the following is ALWAYS TRUE?
(a) f(n) = Ω(g(n)) (b) f(n) = Θ(g(n))
(c) f(n) = O(g(n)) (d) None of the above
4. Which of the given options provides the increasing order of asymptotic complexity of functions f1(n) = 2n
, f2(n) = n3/2
,
f3(n) = nlog2 n, f4(n) = nlog2 n
?
(a) f3,f2,f4,f1 (b) f3,f2,f1,f4 (c) f2,f3,f1,f4 (d) f2,f3,f4,f1
5. Two alternative packages A and B are available for processing a database having 10k
records. Package A requires
0.0001n2
time units and package B requires 10nlog10 n time units to process n records. What is the smallest value of
k for which package B will be preferred over A?
(a) 12 (b) 10 (c) 6 (d) 5
6. A list of n strings, each of length n, is sorted into lexicographic (dictionary) order using the merge-sort algorithm by
a machine that can compare alphabets. The worst case running time of this computation is
(a) O(nlog n) (b) O(n2
log n) (c) O(nlog2
n) (d) O(n2
)
7. Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into
two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required
to sort n elements. Then
(a) T(n) ≤ 2T(n/5) + n (b) T(n) ≤ T(n/5) + T(4n/5) + n
(c) T(n) ≤ 2T(4n/5) + n (d) T(n) ≤ 2T(n/2) + n
8. The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes
in a binary tree of height h is
(a) 2h
− 1 (b) 2h−1
− 1 (c) 2h+1
− 1 (d) 2h+1
2. 9. Given the selection sort function
selection_sort ( int s [ ] , int n)
{
int i , j ;
int min ;
for ( i =0; i<n ; i ++){
min=i ;
for ( j=i +1; j<n ; j++)
i f ( s [ j ] < s [ min ] ) min=j ;
swap(&s [ i ] ,& s [ min ] ) ;
}
}
the maximum number of swaps it might have to do is
(a) O(n2
/log n) (b) O(nlog n) (c) O(n) (d) O(log n)
10. Given a set of n distinct numbers, the fastest algorithm that finds
√
n numbers that are closest to the median has
the asymptotic performance
(a) O(
√
nlog n) (b) O(n) (c) O(nlog n) (d) O(n
√
n)
11. Let A be a sequence of 8 distinct integers sorted in ascending order. How many distinct pairs of sequences, B and
C are there such that (i) each is sorted in ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of
merging B and C gives A?
(a) 2 (b) 30 (c) 56 (d) 256
12. Find the worst inputs for Counting Sort among the following:
(a) A =< 3,5,3,2,2,4,1,6,4,2,4,1 >
(b) A =< 4,1,2,3,5,1,3,6,4,4,1,1 >
(c) A =< 3,5,3,2,2,2,1,6,2,2,2,1 >
(d) A =< 3,3,3,2,2,4,1,1,4,2,4,1 >
13. Find the worst inputs for Insertion Sort among the following (a to z):
(a) A =< a,d,o,b,e,s >
(b) A =< g,l,i,d,e,r >
(c) A =< n,o,m,a,d,s >
(d) A =< z,a,b,i,s,m >
14. Find the worst inputs for Merge Sort among the following (a to z):
(a) A =< a,d,o,b,e,s >
(b) A =< g,l,i,d,e,r >
(c) A =< n,o,m,a,d,s >
(d) A =< z,a,b,i,s,m >
15. Find the worst inputs for Quick Sort (if pivoting is done using the median at every step) among the following:
(a) A =< 3,5,1,6,2,4 >
(b) A =< 6,4,5,3,1,2 >
(c) A =< 3,1,4,5,6,2 >
(d) A =< 6,4,2,5,3,1 >
16. Suppose we use a hash function h to hash n distinct keys into an array T of length m. Assuming sim-
ple uniform hashing, what is the expected number of collisions? Given {{k,l} k ≠ l and h(k) = h(l)}.
(a) n(n+1)
2m
(b) n(n+1)
m
(c) n(n−1)
2m
(d) n(n−1)
m
17. Consider a version of the division method in which h(k) = k mod m, where m = 2p
− 1 and k is a charac-
ter string interpreted in radix 2p
. If we can derive string x from string y by permuting its characters, then
(a) x and y hash to the same value.
(b) x and y hash to the different values.
(c) x and y hash values cannot be defined.
(d) None of the above
18. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash-
ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires strictly more than k probes.
(a) 2k+1
(b) 2−k−1
(c) 2−k
(d) 2−k+1
3. 19. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash-
ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires more than 2log(n) probes.
(a) 1/n (b) n (c) 1/(m + n) (d) 1/n2
20. Suppose that we have numbers between 1 and 1000 in a binary search tree, and we want to search
for the number 363. Which of the following sequences could not be the sequence of nodes examined?
(a) 2, 252, 401, 398, 330, 344, 397, 363
(b) 924, 220, 911, 244, 898, 258, 362, 363
(c) 925, 202, 911, 240, 912, 245, 363
(d) 2, 399, 387, 219, 266, 382, 381, 278, 363
(e) 935, 278, 347, 621, 299, 392, 358, 363
21. If a node in a binary search tree has two children, then its successor has no right child and its predecessor has no left
child.
(a) The statement is true. (b) The statement is false. (c) Cannot say. (d) None of the above.
22. We can sort a given set of n numbers by first building a binary search tree containing these numbers (using TREE-
INSERT repeatedly to insert the numbers one by one) and then printing the numbers by an inorder tree walk.
(a) The worst-case running times for this sorting algorithm is Θ(n2
).
(b) The best-case running times for this sorting algorithm is Θ(n log(n)).
(c) The worst-case running times for this sorting algorithm is Θ(log(n)).
(d) The best-case running times for this sorting algorithm is Θ(n).
23. Suppose a circular queue of capacity (n − 1) elements is implemented with an array of n elements. Assume
that the insertion and deletion operation are carried out using REAR and FRONT as array index variables,
respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
(a) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
(b) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
(c) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
(d) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
24. We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how
many ways can we populate the tree with the given set so that it becomes a binary search tree?
(a) 0 (b) 1 (c) n! (d) 1
n+1
2n
Cn
25. Consider the following C program that attempts to locate an element x in an array Y [] using binary search. The
program is erroneous.
1. f(int Y [10], int x) {
2. int i,j,k;
3. i = 0;j = 9;
4. do {
5. k = (i + j)/2;
6. if( Y [k] < x) i = k; else j = k;
7. } while((Y [k] ≠ x) && (i < j));
8. if(Y [k] == x) printf ("x is in the array ") ;
9. else printf (" x is not in the array ") ;
10. }
On which of the following contents of Y and x does the program fail?
(a) Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
(b) Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
(c) Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
(d) Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
26. In Question 25, the correction needed in the program to make it work properly is
(a) Change line 6 to: if (Y [k] < x) i = k + 1; else j = k − 1;
(b) Change line 6 to: if (Y [k] < x) i = k − 1; else j = k + 1;
(c) Change line 6 to: if (Y [k] ≤ x) i = k; else j = k;
(d) Change line 7 to: }while((Y [k] == x) && (i < j));
4. 27. Consider the following C program segment where CellNode represents a node in a binary tree:
struct CellNode {
struct CellNOde *leftChild;
int element;
struct CellNode *rightChild;
};
int GetValue (struct CellNode *ptr) {
int value = 0;
if (ptr != NULL) {
if ((ptr->leftChild == NULL) && (ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)+ GetValue(ptr->rightChild);
}
return(value);
}
The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is:
(a) the number of nodes in the tree
(b) the number of internal nodes in the tree
(c) the number of leaf nodes in the tree
(d) the height of the tree
28. An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these
n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
(a) At least 2n − c comparisons, for some constant c, are needed.
(b) At most 1.5n − 2 comparisons are needed.
(c) At least nlog2n comparisons are needed.
(d) None of the above.
29. What is the time complexity of the following recursive function:
int DoSomething (int n) {
if (n ≤ 2)
return 1;
else
return (DoSomething (floor(sqrt(n))) + n);
}
(a) Θ(n2
) (b) Θ(nlog2n) (c) Θ(log2n) (d) Θ(log2log2n)
30. In the following C function, let n geqm.
int gcd(n,m){
if (n%m ==0) return m;
n = n%m;
return gcd(m,n);
}
How many recursive calls are made by this function?
(a) Θ(log2n) (b) Ω(n) (c) Θ(log2log2n) (d) Θ(
√
n)
All the best for your remaining mid-semester examinations.