SlideShare a Scribd company logo
1 of 8
Page 3
SECTION 1. Algorithm Analysis [1 pt per prompt = 12 points]
TO DO WELL: Before you work on this section, write down
what W(N) means, and the F(N)s of sorting and searching.
1) What is the purpose of using asymptotic notation
such as O, Omega and Theta instead of using
the exact number of comparisons done by a sorting algorithm?
i.e. why do we use O(n^2) instead of saying 2n^2 + 3n + 4
*Because we are only interested in
2) Computing the Average time complexity for a real-world
problem is difficult.
Explain why by referring back to the formula for computing
A(n).
*Why?
3) Your friend is very excited about having found a sorting
algorithm that
sorts in much less than W(n) =Theta(N^2)comparisons even
though it corrects
only one bad pair per comparison. He thinks this is the fastest
sort ever
and that he will get a Ph.D. tomorrow.
Please teach him why he is wrong.
*Answer:
4) Your friend says she can find a comparison based algorithm
that searches
for an element in an ordered list in much less thanW(N) =
Theta(log N).
Please teach her why she is wrong.
*Answer:
5) Name2Divide and Conquer algorithms we studied in this
class.
*Name:
*Name:
6) Describe 2 Space vs. Time decision cases we discussed in
this class.
In what ways can each be called Space vs. Time?
*Example Algorithms: ________ vs.______________
*Reason:
*Example Data Structures: _________vs.____________
*Reason:
7) Name 2 greedy algorithms we have learned in this class.
*Algorithm for solving/finding:
*Algorithm for solving/finding:
SECTION 2. Sorting [2pts per prompt = 10 points]
Your mean employer has five sorting programs. But they are
labeled
by their descriptions - no names.
Read each label then say which of the following it is:
Heap Sort
Insertion Sort
Merge Sort
Quick Sort
Radix Sort
1) "I am a good choice if you want consistent theta(nlogn) time
and have lots of space."
*Answer: This is
2) "Although I take O(n^2) time in the worst case, on the
average
I only use theta(nlogn) and I do not need as much space as
another divide and conquer algorithm.”
*Answer: This is
3) "I use theta(nlogn) time in the worst case. The data structure
I use is also useful for efficiently implementing priority
queues."
*Answer: This is
4) "Even though my average complexity is theta(n^2), I am a
good choice if you want to sort small files, or large files that
are very nearly in order."
*Answer: This is
5) "I am a good choice if you want to quickly sort a large
number of K digit numeric IDs."
*Answer: This is
SECTION 3. Object-Oriented Programming [2pts per prompt =
16 points]
TO DO WELL: Before you work on this section, re-read the
notes from Week6 and Week7.
1) (inheritance), we placed data members of the base class in
protected.
Why did we do that? Answer each separately.
*Why not private?
*Why not public?
2) You had to overload = to make it work with slists.
*We had to overload=. What’s wrong with the one provided by
C++?
*We had to overload==. What’s wrong with the one provided by
C++?
3) Why did you have to write a copy constructor for linked
lists?
Also, give twocases in which your copy constructor is
automatically invoked in relation to calling regular functions.
*What’s wrong with the one provided by C++?
*Invoked when:
*Invoked when:
4) Why is it useful to use virtual functions with inheritance and
pointers? Explain using the Animals array which contains
pointers to Dog and Cat objects with a virtual function Speak.
*The stated combinations allows
SECTION 4. Binary Search Trees (HW4)[1 pt per prompt = 5
points]
void BST::traverse(Vertex *V) // post order traversal
recursively
{
if (V != NULL)
{
traverse(V->Left);
traverse(V->Right);
cout << V->elem << endl;
}
}
1) Modify the above slightly (just re-order) to do the Depth
First traversalrecursively. What is this traversal called?
*Code:
*Name of the traversal: ____________ order traversal.
2) Why would we want to balance search trees?
(i.e. What is wrong with unbalanced trees?)
What were the two ways (from our notes) of having a balanced
search tree?
*Why:
*Way1:
*Way2:
SECTION 5. GRAPHS: Islands and Bridges [2pts per prompt =
4 points]
800 islands are connected with many two-way bridges (i.e.
lines, not arrows).
You know the cost of maintaining each bridge.
You want to minimize the total maintenance cost by eliminating
some bridges while leaving all the islands connected.
1) What algorithm would you use to solve this problem?
(Algorithm for finding what?)
*Algorithm for finding:
2) How many bridges will you end up with if you used this
algorithm?
*Give the Formula where N = 800:
SECTION 6. ENCYPTION and BIG DATA (from Notes-14)[1
pt per blank = 4 points]
*Fill in the blanks in the following:
Encryption in essential in cybersecurity.
Using RSA, if people want to send messages to Mary, they have
to use her ______ encryption key. She uses her ______
decryption key to decode them.
_______ numbers play an important role in constructing these
keys.
The computer can use big training data to learn to identify or
classify things.
By analyzing a vast number of examples labeled with their
categories, the computer will learn to place unlabeled ones into
these categories. This area of Artificial Intelligence is called
_________ learning.
SECTION 7. MEMORY [1pt per prompt = 3 points]
1) What are garbage cells? i.e. What kind of cells are they and
why do they happen? (Recall that there are 3 kinds of cells and
garbage cells are just one of them)
*What are they?
*Why do they happen?
2) Which garbage collection method from the notes worked
incrementally and also prevented dangling pointers?
*Method:
SECTION 8 NP vs. P Consulting Job [2pts per prompt = 6
points]
1) Your boss says "I want you to find the shortest path that
passes through all the Mars alien bases.
The objective is to infect each base
and thus you cannot return to the same base ever again.
I want an algorithm to do it in Polynomial time."
*What would you say to him? Explain why:
2) 10 years from today, while sleeping, you find a polynomial
time algorithm for bin packing. Congratulations!! What
implication does this have on your answer to the question
above? Whatfamous question have you answered to make you
rich?
*Implication on (1):
*Question answered:
================== THE END
===============================================
====
Page 3SECTION 1.  Algorithm Analysis [1 pt per prompt = 12 poi.docx

More Related Content

Similar to Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx

Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
maxinesmith73660
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
Eman magdy
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
Sure Interview
 
Data Structures & Algorithms Coursework Assignment for Sem.docx
Data Structures & Algorithms Coursework Assignment for Sem.docxData Structures & Algorithms Coursework Assignment for Sem.docx
Data Structures & Algorithms Coursework Assignment for Sem.docx
simonithomas47935
 
Linked list basics
Linked list basicsLinked list basics
Linked list basics
Rajesh Kumar
 

Similar to Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx (20)

Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
 
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures  Design-Notes-Searching-Hashing.pdfAD3251-Data Structures  Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
 
Dat 305 dat305 dat 305 education for service uopstudy.com
Dat 305 dat305 dat 305 education for service   uopstudy.comDat 305 dat305 dat 305 education for service   uopstudy.com
Dat 305 dat305 dat 305 education for service uopstudy.com
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures Basics
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
Data Structures & Algorithms Coursework Assignment for Sem.docx
Data Structures & Algorithms Coursework Assignment for Sem.docxData Structures & Algorithms Coursework Assignment for Sem.docx
Data Structures & Algorithms Coursework Assignment for Sem.docx
 
611+tutorial
611+tutorial611+tutorial
611+tutorial
 
Lecture 11.2 : sorting
Lecture 11.2 :  sortingLecture 11.2 :  sorting
Lecture 11.2 : sorting
 
Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015Debugging Complex Systems - Erlang Factory SF 2015
Debugging Complex Systems - Erlang Factory SF 2015
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
Linked list basics
Linked list basicsLinked list basics
Linked list basics
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 
Data structures
Data structuresData structures
Data structures
 

More from bunyansaturnina

Your taskis to analyze and evaluate how various types of medi.docx
Your taskis to analyze and evaluate how various types of medi.docxYour taskis to analyze and evaluate how various types of medi.docx
Your taskis to analyze and evaluate how various types of medi.docx
bunyansaturnina
 
Your task is to explain the process of the juvenile justice system a.docx
Your task is to explain the process of the juvenile justice system a.docxYour task is to explain the process of the juvenile justice system a.docx
Your task is to explain the process of the juvenile justice system a.docx
bunyansaturnina
 
Your task is to conduct research on the ways that universities p.docx
Your task is to conduct research on the ways that universities p.docxYour task is to conduct research on the ways that universities p.docx
Your task is to conduct research on the ways that universities p.docx
bunyansaturnina
 
Your task is to compare and contrast two artworks  given Below.docx
Your task is to compare and contrast two artworks  given Below.docxYour task is to compare and contrast two artworks  given Below.docx
Your task is to compare and contrast two artworks  given Below.docx
bunyansaturnina
 

More from bunyansaturnina (20)

Your tasks will be to answer questions based on the indicators that .docx
Your tasks will be to answer questions based on the indicators that .docxYour tasks will be to answer questions based on the indicators that .docx
Your tasks will be to answer questions based on the indicators that .docx
 
Your taskYou must identify a specific, local problem (eithe.docx
Your taskYou must identify a specific, local problem (eithe.docxYour taskYou must identify a specific, local problem (eithe.docx
Your taskYou must identify a specific, local problem (eithe.docx
 
Your taskis to analyze and evaluate how various types of medi.docx
Your taskis to analyze and evaluate how various types of medi.docxYour taskis to analyze and evaluate how various types of medi.docx
Your taskis to analyze and evaluate how various types of medi.docx
 
Your task this week is to check the internet and the Common Vulner.docx
Your task this week is to check the internet and the Common Vulner.docxYour task this week is to check the internet and the Common Vulner.docx
Your task this week is to check the internet and the Common Vulner.docx
 
Your task is to take unit I Will Survive Ecosystems and Adaptations.docx
Your task is to take unit I Will Survive Ecosystems and Adaptations.docxYour task is to take unit I Will Survive Ecosystems and Adaptations.docx
Your task is to take unit I Will Survive Ecosystems and Adaptations.docx
 
Your task is to perform and document encryption of Thunderbird Email.docx
Your task is to perform and document encryption of Thunderbird Email.docxYour task is to perform and document encryption of Thunderbird Email.docx
Your task is to perform and document encryption of Thunderbird Email.docx
 
Your task is to explain the process of the juvenile justice system a.docx
Your task is to explain the process of the juvenile justice system a.docxYour task is to explain the process of the juvenile justice system a.docx
Your task is to explain the process of the juvenile justice system a.docx
 
Your task is to create a journalistic profile that focuses on a .docx
Your task is to create a journalistic profile that focuses on a .docxYour task is to create a journalistic profile that focuses on a .docx
Your task is to create a journalistic profile that focuses on a .docx
 
Your task is to evaluate the available evidence on the social, emoti.docx
Your task is to evaluate the available evidence on the social, emoti.docxYour task is to evaluate the available evidence on the social, emoti.docx
Your task is to evaluate the available evidence on the social, emoti.docx
 
Your task is to conduct research on the ways that universities p.docx
Your task is to conduct research on the ways that universities p.docxYour task is to conduct research on the ways that universities p.docx
Your task is to conduct research on the ways that universities p.docx
 
Your task is to compare and contrast two artworks  given Below.docx
Your task is to compare and contrast two artworks  given Below.docxYour task is to compare and contrast two artworks  given Below.docx
Your task is to compare and contrast two artworks  given Below.docx
 
Your task is to create a personal essay that focuses on your per.docx
Your task is to create a personal essay that focuses on your per.docxYour task is to create a personal essay that focuses on your per.docx
Your task is to create a personal essay that focuses on your per.docx
 
Your Task is to Carry out an independent research study (.docx
Your Task is to Carry out an independent research study (.docxYour Task is to Carry out an independent research study (.docx
Your Task is to Carry out an independent research study (.docx
 
Your Research Project is due this week. It must consist of1. 5 .docx
Your Research Project is due this week. It must consist of1. 5 .docxYour Research Project is due this week. It must consist of1. 5 .docx
Your Research Project is due this week. It must consist of1. 5 .docx
 
Your supervisor wants the staff to understand the importance of.docx
Your supervisor wants the staff to understand the importance of.docxYour supervisor wants the staff to understand the importance of.docx
Your supervisor wants the staff to understand the importance of.docx
 
Your supervisor has asked you to create a new entity-relationship di.docx
Your supervisor has asked you to create a new entity-relationship di.docxYour supervisor has asked you to create a new entity-relationship di.docx
Your supervisor has asked you to create a new entity-relationship di.docx
 
Your supervisor asks you to lead a team of paralegals in the office .docx
Your supervisor asks you to lead a team of paralegals in the office .docxYour supervisor asks you to lead a team of paralegals in the office .docx
Your supervisor asks you to lead a team of paralegals in the office .docx
 
Your research paper final must be written using APA style and incl.docx
Your research paper final must be written using APA style and incl.docxYour research paper final must be written using APA style and incl.docx
Your research paper final must be written using APA style and incl.docx
 
Your submission should be a PowerPoint slide presentation with 1.docx
Your submission should be a PowerPoint slide presentation with 1.docxYour submission should be a PowerPoint slide presentation with 1.docx
Your submission should be a PowerPoint slide presentation with 1.docx
 
your research must includeExecutive summaryAbstractP.docx
your research must includeExecutive summaryAbstractP.docxyour research must includeExecutive summaryAbstractP.docx
your research must includeExecutive summaryAbstractP.docx
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 

Page 3SECTION 1. Algorithm Analysis [1 pt per prompt = 12 poi.docx

  • 1. Page 3 SECTION 1. Algorithm Analysis [1 pt per prompt = 12 points] TO DO WELL: Before you work on this section, write down what W(N) means, and the F(N)s of sorting and searching. 1) What is the purpose of using asymptotic notation such as O, Omega and Theta instead of using the exact number of comparisons done by a sorting algorithm? i.e. why do we use O(n^2) instead of saying 2n^2 + 3n + 4 *Because we are only interested in 2) Computing the Average time complexity for a real-world problem is difficult. Explain why by referring back to the formula for computing A(n). *Why? 3) Your friend is very excited about having found a sorting algorithm that sorts in much less than W(n) =Theta(N^2)comparisons even though it corrects only one bad pair per comparison. He thinks this is the fastest sort ever and that he will get a Ph.D. tomorrow. Please teach him why he is wrong. *Answer: 4) Your friend says she can find a comparison based algorithm
  • 2. that searches for an element in an ordered list in much less thanW(N) = Theta(log N). Please teach her why she is wrong. *Answer: 5) Name2Divide and Conquer algorithms we studied in this class. *Name: *Name: 6) Describe 2 Space vs. Time decision cases we discussed in this class. In what ways can each be called Space vs. Time? *Example Algorithms: ________ vs.______________ *Reason: *Example Data Structures: _________vs.____________ *Reason: 7) Name 2 greedy algorithms we have learned in this class. *Algorithm for solving/finding: *Algorithm for solving/finding: SECTION 2. Sorting [2pts per prompt = 10 points] Your mean employer has five sorting programs. But they are labeled by their descriptions - no names. Read each label then say which of the following it is: Heap Sort
  • 3. Insertion Sort Merge Sort Quick Sort Radix Sort 1) "I am a good choice if you want consistent theta(nlogn) time and have lots of space." *Answer: This is 2) "Although I take O(n^2) time in the worst case, on the average I only use theta(nlogn) and I do not need as much space as another divide and conquer algorithm.” *Answer: This is 3) "I use theta(nlogn) time in the worst case. The data structure I use is also useful for efficiently implementing priority queues." *Answer: This is 4) "Even though my average complexity is theta(n^2), I am a good choice if you want to sort small files, or large files that are very nearly in order." *Answer: This is 5) "I am a good choice if you want to quickly sort a large number of K digit numeric IDs." *Answer: This is SECTION 3. Object-Oriented Programming [2pts per prompt = 16 points]
  • 4. TO DO WELL: Before you work on this section, re-read the notes from Week6 and Week7. 1) (inheritance), we placed data members of the base class in protected. Why did we do that? Answer each separately. *Why not private? *Why not public? 2) You had to overload = to make it work with slists. *We had to overload=. What’s wrong with the one provided by C++? *We had to overload==. What’s wrong with the one provided by C++? 3) Why did you have to write a copy constructor for linked lists? Also, give twocases in which your copy constructor is automatically invoked in relation to calling regular functions. *What’s wrong with the one provided by C++? *Invoked when: *Invoked when: 4) Why is it useful to use virtual functions with inheritance and pointers? Explain using the Animals array which contains pointers to Dog and Cat objects with a virtual function Speak. *The stated combinations allows SECTION 4. Binary Search Trees (HW4)[1 pt per prompt = 5
  • 5. points] void BST::traverse(Vertex *V) // post order traversal recursively { if (V != NULL) { traverse(V->Left); traverse(V->Right); cout << V->elem << endl; } } 1) Modify the above slightly (just re-order) to do the Depth First traversalrecursively. What is this traversal called? *Code: *Name of the traversal: ____________ order traversal. 2) Why would we want to balance search trees? (i.e. What is wrong with unbalanced trees?) What were the two ways (from our notes) of having a balanced search tree? *Why: *Way1: *Way2: SECTION 5. GRAPHS: Islands and Bridges [2pts per prompt =
  • 6. 4 points] 800 islands are connected with many two-way bridges (i.e. lines, not arrows). You know the cost of maintaining each bridge. You want to minimize the total maintenance cost by eliminating some bridges while leaving all the islands connected. 1) What algorithm would you use to solve this problem? (Algorithm for finding what?) *Algorithm for finding: 2) How many bridges will you end up with if you used this algorithm? *Give the Formula where N = 800: SECTION 6. ENCYPTION and BIG DATA (from Notes-14)[1 pt per blank = 4 points] *Fill in the blanks in the following: Encryption in essential in cybersecurity. Using RSA, if people want to send messages to Mary, they have to use her ______ encryption key. She uses her ______ decryption key to decode them. _______ numbers play an important role in constructing these keys. The computer can use big training data to learn to identify or classify things. By analyzing a vast number of examples labeled with their categories, the computer will learn to place unlabeled ones into these categories. This area of Artificial Intelligence is called _________ learning. SECTION 7. MEMORY [1pt per prompt = 3 points] 1) What are garbage cells? i.e. What kind of cells are they and why do they happen? (Recall that there are 3 kinds of cells and
  • 7. garbage cells are just one of them) *What are they? *Why do they happen? 2) Which garbage collection method from the notes worked incrementally and also prevented dangling pointers? *Method: SECTION 8 NP vs. P Consulting Job [2pts per prompt = 6 points] 1) Your boss says "I want you to find the shortest path that passes through all the Mars alien bases. The objective is to infect each base and thus you cannot return to the same base ever again. I want an algorithm to do it in Polynomial time." *What would you say to him? Explain why: 2) 10 years from today, while sleeping, you find a polynomial time algorithm for bin packing. Congratulations!! What implication does this have on your answer to the question above? Whatfamous question have you answered to make you rich? *Implication on (1): *Question answered: ================== THE END =============================================== ====