SlideShare a Scribd company logo
National School of Business Management
Algorithms and Data Structures
CS106.3 - 16.2 Examination
Time: 03Hrs
Answer all Questions Date: 2017
Question 1 – 20 Marks
(a) What is asymptotic analysis in the context of evaluation of Algorithms? [5 Marks]
(b) Simplify the following Big-O expressions [10 Marks]
i. O(10n4-n2-10)
ii. O(2n3+102n) * O(n)
iii. O(n2) + O(5*log(n))
iv. O(n2) * O(5*log(n))
v. n2*O(n2)
(c) Giving reasons, evaluate the time complexity of the following function. [5 Marks]
int swapping;
do {
for(i=0,swapping=0;i<size-1;i++)
if(data[i]>data[i+1]) { temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
swapping=1;
}
} while(swapping)
Question 2 - 20 Marks
Following loop implements the insertion sort algorithm.
1 for(k=1; k<size; k++){
2 for(i=0; i<k && d[i]<=d[k]; i++);
3 temp=d[k];
4 for(l=k;l>i;l--) d[l]=d[l-1];
5 d[i]=temp;
6 }
(a) Write a complete C function to implement the insertion sort algorithm. [5 marks]
(b) Write down a comment line for each and every line in the above C function in part (a). If
necessary number the lines in the C function and write the comments separately with
the line numbers. [5marks]
(c) Copy the following table into your answer script and complete it for each iteration of the
outer loop (loop using k) for the problem scenario given below to carry out a desk-check
of the code given above.
Variable initially After
iteration
1
After
iteration
2
After
iteration
3
After
iteration
4
…
Array d[] 12,25,9,2,
20,15,8
size 7
k 1
d[k] 25
i NA
d[i] NA
Problem Scenario:
array[]
12 25 9 2 20 15 8
[10 Marks]
Question 3 - 20 Marks
(a) Show diagrammatically, the operation of a queue implemented via a circular array
assuming the array size to be 8. Draw diagrams to show the status of the queue for the
following, clearly indicating the position of the head/front and tail/rear.
i. empty queue
ii. after enqueueing 4 items; 12, 23, 8 and 15
iii. full queue [6 Marks]
(b) Suggest a method to differentiate an empty queue (in section (a) above) from a full
queue by comparing the values of head and tail. [5 Marks]
(c) Implement 3 functions, including either enqueue() or dequeue(), of the queue
specification given below. Utilize your suggestion in part (b) above. [9 Marks]
struct queue { int head, tail;
int data[size]; };
int enqueue(struct queue *q, int item);
int dequeue(struct queue*q);
int init(struct queue* q); // set head and tail
int full(struct queue* q); // return 1 if full
int empty(struct queue* q); // return 1 if empty
Question 4 - 20 Marks
Following incomplete code segment intends to implement the linear search algorithm.
int lsearch(float data[], int size, float key){
int found = 0;
int position = –1;
int index = 0;
(a) Complete the above code to using appropriate syntax. [6 marks]
(b) Write down a comment line you would include in the above code against each line to
illustrate the function of each line or statement. You do not have to copy the code –
just put the line number and your comment in your answer script. [4 marks]
Following lines were extracted from a typical linked list implementation prototype in C.
// data structure for a node
struct node { float data;
struct node* next;};
//creates a node with data value (item) & returns the node address
struct node* makeNode(float item);
// add a new node to the head
struct node* addHead(struct node** list, float item);
// add a new node to the tail
struct node* addTail(struct node** list, float item);
(c) Write code for the above three functions to derive the linked list implementation.
[10 marks]
Question 5 - 20 Marks
(a) Draw a binary search tree (BST) generated by inserting the following items in the given
order.
54, 15, 12, 64, 51, 9, 85, 15, 24, 3 [6 Marks]
(b) Draw the sequence of items you process, if the BST is traversed by,
i. pre-order,
ii. in-order,
iii. post-order, tree walking methods. [6 marks]
(c) Write down a node structure in C, suitable to implement the above BST. [2 marks]
(d) Write a C function to return the minimum value stored in a BST. [4 Marks]
(e) Explain the use of tree data structure in a computer application. [2 Marks]

More Related Content

What's hot

Implementation
ImplementationImplementation
Implementation
Syed Zaid Irshad
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
annaunivedu
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
Pranoti Doke
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
Hossain Md Shakhawat
 
X10707 (me8691)
X10707 (me8691)X10707 (me8691)
X10707 (me8691)
BIBIN CHIDAMBARANATHAN
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
RamKumar42580
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
hemalatha athinarayanan
 
Digital logic design1
Digital logic design1Digital logic design1
Digital logic design1
jntuworld
 
Algorithms
AlgorithmsAlgorithms
Algorithms
Santosh Rajan
 
Lumpkin Graphing functions
Lumpkin Graphing functionsLumpkin Graphing functions
Lumpkin Graphing functions
renialumpkin
 
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPEREC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
VISHNUPRABHANKAIMAL
 
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple GraphsData Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple Graphs
Rsquared Academy
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
Rajendran
 
Queue
QueueQueue
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
Mumbai B.Sc.IT Study
 

What's hot (19)

Implementation
ImplementationImplementation
Implementation
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
X10707 (me8691)
X10707 (me8691)X10707 (me8691)
X10707 (me8691)
 
chapter-8.ppt
chapter-8.pptchapter-8.ppt
chapter-8.ppt
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
 
Digital logic design1
Digital logic design1Digital logic design1
Digital logic design1
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Lumpkin Graphing functions
Lumpkin Graphing functionsLumpkin Graphing functions
Lumpkin Graphing functions
 
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPEREC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
 
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple GraphsData Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple Graphs
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Graphing functions
Graphing functionsGraphing functions
Graphing functions
 
Queue
QueueQueue
Queue
 
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 
Ch3
Ch3Ch3
Ch3
 

Similar to Doc 20180130-wa0004-1

Computer science ms
Computer science msComputer science ms
Computer science ms
B Bhuvanesh
 
6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2
kvs
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
Fwdays
 
Data structure manual
Data structure manualData structure manual
Data structure manual
sameer farooq
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
lakshmi r
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
kvs
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
Platonov Sergey
 
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdf
wasemanivytreenrco51
 
Vtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papersVtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papers
megharajk
 
8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structuresjntuworld
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
Nguyễn Đăng Đức
 
Adobe
AdobeAdobe
CS_PQMS.pdf
CS_PQMS.pdfCS_PQMS.pdf
CS_PQMS.pdf
justforwatching72
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
LavanyaJ28
 
5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 

Similar to Doc 20180130-wa0004-1 (20)

Computer science ms
Computer science msComputer science ms
Computer science ms
 
6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
 
Data structure manual
Data structure manualData structure manual
Data structure manual
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Bcsl 033 solve assignment
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdf
 
Vtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papersVtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papers
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...
 
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
Adobe
AdobeAdobe
Adobe
 
CS_PQMS.pdf
CS_PQMS.pdfCS_PQMS.pdf
CS_PQMS.pdf
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...
 

More from HarithaRanasinghe

Session11 single dimarrays
Session11 single dimarraysSession11 single dimarrays
Session11 single dimarrays
HarithaRanasinghe
 
Session09 multi dimarrays
Session09 multi dimarraysSession09 multi dimarrays
Session09 multi dimarrays
HarithaRanasinghe
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
HarithaRanasinghe
 
Session04 selection structure_b
Session04 selection structure_bSession04 selection structure_b
Session04 selection structure_b
HarithaRanasinghe
 
Session04 selection structure_a
Session04 selection structure_aSession04 selection structure_a
Session04 selection structure_a
HarithaRanasinghe
 
Session01 basics programming
Session01 basics programmingSession01 basics programming
Session01 basics programming
HarithaRanasinghe
 
Sad sample paper - mcq answers
Sad   sample paper - mcq answersSad   sample paper - mcq answers
Sad sample paper - mcq answers
HarithaRanasinghe
 
Model paper algorithms and data structures
Model paper  algorithms and data structuresModel paper  algorithms and data structures
Model paper algorithms and data structures
HarithaRanasinghe
 

More from HarithaRanasinghe (20)

Session12 pointers
Session12 pointersSession12 pointers
Session12 pointers
 
Session11 single dimarrays
Session11 single dimarraysSession11 single dimarrays
Session11 single dimarrays
 
Session09 multi dimarrays
Session09 multi dimarraysSession09 multi dimarrays
Session09 multi dimarrays
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Session06 functions
Session06 functionsSession06 functions
Session06 functions
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
Session04 selection structure_b
Session04 selection structure_bSession04 selection structure_b
Session04 selection structure_b
 
Session04 selection structure_a
Session04 selection structure_aSession04 selection structure_a
Session04 selection structure_a
 
Session03 operators
Session03 operatorsSession03 operators
Session03 operators
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 
Session01 basics programming
Session01 basics programmingSession01 basics programming
Session01 basics programming
 
Program flow charts
Program flow chartsProgram flow charts
Program flow charts
 
Sad -sample_paper
Sad  -sample_paperSad  -sample_paper
Sad -sample_paper
 
Sad sample paper - mcq answers
Sad   sample paper - mcq answersSad   sample paper - mcq answers
Sad sample paper - mcq answers
 
Paper
PaperPaper
Paper
 
Model questions
Model questionsModel questions
Model questions
 
Model paper algorithms and data structures
Model paper  algorithms and data structuresModel paper  algorithms and data structures
Model paper algorithms and data structures
 
Doc 20180208-wa0001
Doc 20180208-wa0001Doc 20180208-wa0001
Doc 20180208-wa0001
 
Doc 20180130-wa0005
Doc 20180130-wa0005Doc 20180130-wa0005
Doc 20180130-wa0005
 
Doc 20180130-wa0004
Doc 20180130-wa0004Doc 20180130-wa0004
Doc 20180130-wa0004
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 

Doc 20180130-wa0004-1

  • 1. National School of Business Management Algorithms and Data Structures CS106.3 - 16.2 Examination Time: 03Hrs Answer all Questions Date: 2017 Question 1 – 20 Marks (a) What is asymptotic analysis in the context of evaluation of Algorithms? [5 Marks] (b) Simplify the following Big-O expressions [10 Marks] i. O(10n4-n2-10) ii. O(2n3+102n) * O(n) iii. O(n2) + O(5*log(n)) iv. O(n2) * O(5*log(n)) v. n2*O(n2) (c) Giving reasons, evaluate the time complexity of the following function. [5 Marks] int swapping; do { for(i=0,swapping=0;i<size-1;i++) if(data[i]>data[i+1]) { temp=data[i]; data[i]=data[i+1]; data[i+1]=temp; swapping=1; } } while(swapping) Question 2 - 20 Marks Following loop implements the insertion sort algorithm. 1 for(k=1; k<size; k++){ 2 for(i=0; i<k && d[i]<=d[k]; i++); 3 temp=d[k]; 4 for(l=k;l>i;l--) d[l]=d[l-1]; 5 d[i]=temp; 6 }
  • 2. (a) Write a complete C function to implement the insertion sort algorithm. [5 marks] (b) Write down a comment line for each and every line in the above C function in part (a). If necessary number the lines in the C function and write the comments separately with the line numbers. [5marks] (c) Copy the following table into your answer script and complete it for each iteration of the outer loop (loop using k) for the problem scenario given below to carry out a desk-check of the code given above. Variable initially After iteration 1 After iteration 2 After iteration 3 After iteration 4 … Array d[] 12,25,9,2, 20,15,8 size 7 k 1 d[k] 25 i NA d[i] NA Problem Scenario: array[] 12 25 9 2 20 15 8 [10 Marks] Question 3 - 20 Marks (a) Show diagrammatically, the operation of a queue implemented via a circular array assuming the array size to be 8. Draw diagrams to show the status of the queue for the following, clearly indicating the position of the head/front and tail/rear. i. empty queue ii. after enqueueing 4 items; 12, 23, 8 and 15 iii. full queue [6 Marks] (b) Suggest a method to differentiate an empty queue (in section (a) above) from a full queue by comparing the values of head and tail. [5 Marks] (c) Implement 3 functions, including either enqueue() or dequeue(), of the queue specification given below. Utilize your suggestion in part (b) above. [9 Marks]
  • 3. struct queue { int head, tail; int data[size]; }; int enqueue(struct queue *q, int item); int dequeue(struct queue*q); int init(struct queue* q); // set head and tail int full(struct queue* q); // return 1 if full int empty(struct queue* q); // return 1 if empty Question 4 - 20 Marks Following incomplete code segment intends to implement the linear search algorithm. int lsearch(float data[], int size, float key){ int found = 0; int position = –1; int index = 0; (a) Complete the above code to using appropriate syntax. [6 marks] (b) Write down a comment line you would include in the above code against each line to illustrate the function of each line or statement. You do not have to copy the code – just put the line number and your comment in your answer script. [4 marks] Following lines were extracted from a typical linked list implementation prototype in C. // data structure for a node struct node { float data; struct node* next;}; //creates a node with data value (item) & returns the node address struct node* makeNode(float item); // add a new node to the head struct node* addHead(struct node** list, float item); // add a new node to the tail struct node* addTail(struct node** list, float item); (c) Write code for the above three functions to derive the linked list implementation. [10 marks]
  • 4. Question 5 - 20 Marks (a) Draw a binary search tree (BST) generated by inserting the following items in the given order. 54, 15, 12, 64, 51, 9, 85, 15, 24, 3 [6 Marks] (b) Draw the sequence of items you process, if the BST is traversed by, i. pre-order, ii. in-order, iii. post-order, tree walking methods. [6 marks] (c) Write down a node structure in C, suitable to implement the above BST. [2 marks] (d) Write a C function to return the minimum value stored in a BST. [4 Marks] (e) Explain the use of tree data structure in a computer application. [2 Marks]