SlideShare a Scribd company logo
1 of 6
Data Structures and Algorithm Analysis
1. How much memory will the following structures take up?
Hint: int takes 4 bytes, float takes 4 bytes, char takes 1 byte. – 9
points
a. struct Structure1 {int a,b,c,d,e[10]; float f;};
b. struct Structure2 {int a[12]; float b[5];};
c. struct Structure3 {char a[10][12][4], b[5][5], c[10];};
2. Show the steps when sorting (smallest to largest) the
following arrays of numbers using
selection sort
i.e. every time a swap occurs, show what the current state of
the array looks like, including the final sorted array. – 12 points
a. [10, 2, 5, 8, 9, 1, 4, 7]
b. [7, 1, 3, 2, 5, 4, 8, 12, 9]
c. [8, 7, 6, 5, 4, 3, 2, 1]
d. [5, 3, 8, 1, 9, 4, 2, 6]
3. Big-O: What is meant by f(n) = O(g(n))? Give the definition
and then explain what it means in your own terms. – 5 points
4. Big-Omega: What is meant by f(n) = Ω(g(n))? Give the
definition and then explain what it means in your own terms. –
5 points
5. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
6. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
7. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
8. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
9. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
10. What principle governs how you add/remove elements in a
stack? Spell it out and briefly explain. - 4 points
11. Briefly describe an application of a stack. - 4 points
12. What principle governs how you add/remove elements in a
queue? Spell it out and briefly explain. - 4 points
13. Briefly describe an application of a queue. - 4 points
Consider the following graph (pseudocode for BFS and DFS
given on page 9):
14. Write the order in which the nodes would be visited in when
doing a
breadth first search (BFS)
traversal starting at
node 4
. Also, write the distances from 4 to every other node. - 6 points
15. Write the order in which the nodes would be visited in when
doing a
breadth first search (BFS)
traversal starting at
node 5
. Also, write the distances from 5 to every other node. - 6 points
Same graph (for your convenience):
16. Write the order in which the nodes would be visited in when
doing a
depth first search (DFS)
traversal starting at
node 4 (order discovered or order off the stack)
. - 6 points
17. Write the order in which the nodes would be visited in when
doing a
depth first search (DFS)
traversal starting at
node 5 (order discovered or order off the stack)
. - 6 points
18. Give the definition of a graph. - 5 points
19. Give the definition of a tree (from graph theory). - 4 points
BFS Pseudocode (for graph with n vertices):
Input: grapharray[n][n], source
queue Q
int distance[n] (array to keep track of nodes distances (from
source), all values set to -1 except source which is set to 0
i.e. -1 = not visited)
Q.push(source)
while(Q is not empty)
v = Q.front
Q.pop()
for each neighbor w of v
if distance[w] = -1
print w
distance[w] = distance[v]+1
Q.push(w)
end if
end for
end while
DFS Pseudocode (for graph with n vertices):
Input: grapharray[n][n], source
stack S
int visited[n] (array to keep track of nodes visited, all values
set to 0 except source which is set to 1 i.e. 0 = not visited, 1
= visited)
S.push(source)
while(S is not empty)
v = S.top
S.pop()
for each neighbor w of v
if visited[w] = 0
print w
visited[w] = 1
S.push(w)
end if
end for
end while
Bonus (4 points): Show
all
of the steps (splitting and merging) when using mergesort to
sort (smallest to largest) the following array (they are the
numbers 1 through 16):
[16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]
Bonus (2 points): describe how you could implement a queue
using 2 stacks.
Bonus (4 points) Draw the binary search tree that would be
constructed by inserting the following values in the exact order
given (starting with an empty tree i.e. first value will be the
first node in the tree): -
a. Binary Search Tree A: 8, 9, 2, 7, 1, 10, 3, 5, 6, 4
b. Binary Search Tree B: 10, 7, 9, 12, 4, 2, 5, 3, 1, 14, 11, 19,
13, 18, 20

More Related Content

Similar to Data Structures and Algorithms Analysis

bfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxbfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxsaurabhpandey679381
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxwhittemorelucilla
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsSigSegVSquad
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Shuvongkor Barman
 
hospital management
hospital managementhospital management
hospital managementguestbcbbb5c
 
lecture 17
lecture 17lecture 17
lecture 17sajinsc
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxmariuse18nolet
 
Breadth first search (Bfs)
Breadth first search (Bfs)Breadth first search (Bfs)
Breadth first search (Bfs)Ishucs
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questionsGradeup
 

Similar to Data Structures and Algorithms Analysis (20)

bfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxbfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptx
 
Graphs
GraphsGraphs
Graphs
 
Graph
GraphGraph
Graph
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
hospital management
hospital managementhospital management
hospital management
 
lecture 17
lecture 17lecture 17
lecture 17
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
 
Graphs
GraphsGraphs
Graphs
 
Parallel search
Parallel searchParallel search
Parallel search
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docx
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Breadth first search (Bfs)
Breadth first search (Bfs)Breadth first search (Bfs)
Breadth first search (Bfs)
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questions
 
Graph
GraphGraph
Graph
 

More from randyburney60861

Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxDelusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxrandyburney60861
 
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxDemand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxrandyburney60861
 
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxDeloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxrandyburney60861
 
DELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxDELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxrandyburney60861
 
Deliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxDeliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxrandyburney60861
 
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxDeliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxrandyburney60861
 
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxDeliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxrandyburney60861
 
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxDeliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxrandyburney60861
 
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxDeliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxrandyburney60861
 
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxDeliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxrandyburney60861
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxrandyburney60861
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxrandyburney60861
 
DEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxDEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxrandyburney60861
 
Definition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxDefinition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxrandyburney60861
 
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxDefinition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxrandyburney60861
 
Definition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxDefinition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxrandyburney60861
 
Definition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxDefinition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxrandyburney60861
 
DEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxDEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxrandyburney60861
 
Defining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxDefining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxrandyburney60861
 
Define      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxDefine      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxrandyburney60861
 

More from randyburney60861 (20)

Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxDelusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
 
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxDemand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
 
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxDeloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
 
DELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxDELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docx
 
Deliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxDeliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docx
 
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxDeliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
 
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxDeliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
 
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxDeliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
 
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxDeliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
 
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxDeliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
 
DEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxDEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docx
 
Definition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxDefinition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docx
 
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxDefinition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
 
Definition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxDefinition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docx
 
Definition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxDefinition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docx
 
DEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxDEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docx
 
Defining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxDefining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docx
 
Define      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxDefine      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docx
 

Recently uploaded

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 

Recently uploaded (20)

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 

Data Structures and Algorithms Analysis

  • 1. Data Structures and Algorithm Analysis 1. How much memory will the following structures take up? Hint: int takes 4 bytes, float takes 4 bytes, char takes 1 byte. – 9 points a. struct Structure1 {int a,b,c,d,e[10]; float f;}; b. struct Structure2 {int a[12]; float b[5];}; c. struct Structure3 {char a[10][12][4], b[5][5], c[10];}; 2. Show the steps when sorting (smallest to largest) the following arrays of numbers using selection sort i.e. every time a swap occurs, show what the current state of the array looks like, including the final sorted array. – 12 points a. [10, 2, 5, 8, 9, 1, 4, 7] b. [7, 1, 3, 2, 5, 4, 8, 12, 9] c. [8, 7, 6, 5, 4, 3, 2, 1] d. [5, 3, 8, 1, 9, 4, 2, 6] 3. Big-O: What is meant by f(n) = O(g(n))? Give the definition and then explain what it means in your own terms. – 5 points 4. Big-Omega: What is meant by f(n) = Ω(g(n))? Give the definition and then explain what it means in your own terms. – 5 points
  • 2. 5. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 6. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 7. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 8. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 9. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 10. What principle governs how you add/remove elements in a stack? Spell it out and briefly explain. - 4 points 11. Briefly describe an application of a stack. - 4 points 12. What principle governs how you add/remove elements in a queue? Spell it out and briefly explain. - 4 points 13. Briefly describe an application of a queue. - 4 points Consider the following graph (pseudocode for BFS and DFS given on page 9): 14. Write the order in which the nodes would be visited in when
  • 3. doing a breadth first search (BFS) traversal starting at node 4 . Also, write the distances from 4 to every other node. - 6 points 15. Write the order in which the nodes would be visited in when doing a breadth first search (BFS) traversal starting at node 5 . Also, write the distances from 5 to every other node. - 6 points Same graph (for your convenience): 16. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 4 (order discovered or order off the stack) . - 6 points 17. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 5 (order discovered or order off the stack) . - 6 points 18. Give the definition of a graph. - 5 points 19. Give the definition of a tree (from graph theory). - 4 points
  • 4. BFS Pseudocode (for graph with n vertices): Input: grapharray[n][n], source queue Q int distance[n] (array to keep track of nodes distances (from source), all values set to -1 except source which is set to 0 i.e. -1 = not visited) Q.push(source) while(Q is not empty) v = Q.front Q.pop() for each neighbor w of v if distance[w] = -1 print w distance[w] = distance[v]+1 Q.push(w) end if end for end while
  • 5. DFS Pseudocode (for graph with n vertices): Input: grapharray[n][n], source stack S int visited[n] (array to keep track of nodes visited, all values set to 0 except source which is set to 1 i.e. 0 = not visited, 1 = visited) S.push(source) while(S is not empty) v = S.top S.pop() for each neighbor w of v if visited[w] = 0 print w visited[w] = 1 S.push(w) end if end for end while Bonus (4 points): Show all
  • 6. of the steps (splitting and merging) when using mergesort to sort (smallest to largest) the following array (they are the numbers 1 through 16): [16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8] Bonus (2 points): describe how you could implement a queue using 2 stacks. Bonus (4 points) Draw the binary search tree that would be constructed by inserting the following values in the exact order given (starting with an empty tree i.e. first value will be the first node in the tree): - a. Binary Search Tree A: 8, 9, 2, 7, 1, 10, 3, 5, 6, 4 b. Binary Search Tree B: 10, 7, 9, 12, 4, 2, 5, 3, 1, 14, 11, 19, 13, 18, 20