COMP2336_Assignmet_2
.docx
keyboard_arrow_up
School
Prairie View A&M University *
*We aren’t endorsed by this school
Course
2336
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
4
Uploaded by martaesia1216
Assignment 2
COMP 2336 – Data Structures and Algorithms
Fall 2023 Dr. Noushin
Ghaffari
Important notes:
•
Due Date: 10/11/23, 10:00 AM Deliverable:
Option 1: A Microsoft Word document or a PDF file submitted on
PVAMU Canvas
Option 2: all the answers can be typed on Canvas editor directly
•
All the questions are from the textbook and instructor lectures. The answers are in the
book, slides or were mentioned in the class.
•
Individual assignment: no team work is allowed.
•
Follow all the university rules from the student handbook regarding plagiarism and
honesty.
•
Wishing you the best! Use this assignment as a great way to review class material one
more time and utilize them in your work.
1.
Indicate whether a stack would be a suitable data structure for each of the following
applications. Elaborate your answer.
(8 points)
a)
A program to evaluate arithmetic expressions according to the specific order of operators
Yes, a stack is suitable because stacks are usually used for assessing arithmetic
methods, and a stack helps keep track of the particular order.
b)
A bank simulation of its teller operation to see how waiting times would be affected by
adding another teller
No, a stack would not be suitable because this application deals
with First In, First Out, which are queues. Stacks handle Last In, First Out.
c)
A program to receive data that are to be saved and processed in the reverse order
Yes, a
stack is suitable because as this application is being pushed in, when the application
is being processed in reverse order, it will pop out.
d)
An address book to be maintained
Maybe a stack could be suitable depending on
what the address book is being maintained on. If a stack were being used to track
recently added addresses, then a stack would be appropriate.
2.
(Multiple choice
(4 points))
The statements
stack.Push(item1 + 1);
stack.Pop(item1 + 1);
in the client program
a)
would cause a syntax error at compile time.
b)
would cause a run-time error
c)
would be legal, but would violate the encapsulation of the stack
d)
would be perfectly legal and appropriate.
3.
Show what is written by the following segments of code, given that item1, item2, and item3 are
int variables. Show step by step what would be stored in each variable after each line of the
code.
(18 points)
Hint: the code for question is already provided. You need to trace the code and show the outputs in each
step. Basically show the stack contents in different stages, after each push and pop and print operation.
You can use pen and pencil and then scan your answers or just use a table in word for example.
a)
Answers on the next page
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Automatic generation of Databases: Python
Would anyone have some tips/pointers on writing some code that takes an input file (csv) that contains a number of columns and rows such as Job title, Salary etc. but does not have information such as Name, Address, phone number etc. I have been messing around with the Python Library 'Faker' which has been doing well but I need some advice on making the overal user experience look better. Could someone recommend a good GUI library/package to test with. I love the look of Tableau Dashboards. I would like to be able to display possibly two to six different algorithmic stats to generate the fake data to then be saved in a new output file.A little bit of a strange question I know but any tips greatly appreciated :D
arrow_forward
want accurate answer
If answer copied from existing answer from chegg or bartleby I report the answer to support team
dont post existing answers
arrow_forward
Frames are a type of data structure used in artificial intelligence for representing stereotypical situations. They contain slots that hold values or other frames, and these slots can represent properties or attributes of the situation. What possible properties or attributes would a frame have for an animal such as a 'bird'?
arrow_forward
6:40
Back
Assignment Details
Object Oriented Programming
Student
first_name : string
last_name: string
id: int
gpa : double
major: string
+ set(): void
+ print(): void
Sample Run (User input in bold):
Student Information Database
First Name: Elaine
Last Name: Benes
ID: 1961
GPA: 4.0
Major: French_Literature
First Name: George
Last Name: Costanza
◄ Previous
Submit Assignment
Dashboard Calendar
7
To Do
C
Notifications
LTE 264
Next ►
Inbox
arrow_forward
2) After a data-mining course the results of the exam was recorded along with some data about the students.
The results can be found in in the table below. (GPA is the Grade Point Average.)
ID Phone number Language Passed all assignments GPA Passed exam
555 - 3452
555 - 6294
1
Java
No
3.1
Yes
Java
No
2.0
No
3
555 - 9385
C++
Yes
3.5
Yes
4
555 - 9387
Python
Yes
2.5
Yes
555 - 9284
555 - 0293
555 - 9237
555 - 3737
Java
Yes
3.9
No
C++
No
2.9
No
7
Java
No
1.9
No
8
Python
Yes
3.2
Yes
In no more than one page of text, describe the design of a K-Nearest Neighbor classifier to predict
which student will fail or pass the exam.
b. Use your K-NN classifier to predict if the following student (who has slept too much and missed
the main test) will succeed in the retest.
а.
ID Phone number Language Passed all assignments GPA Passed exam
Yes
555 - 6295
C++
3.0
?
arrow_forward
In your original post, answer the following:
Discuss the following about Libraries:
Describe what a Library is, and a programming example where the use of a Library would be beneficial.
Because you will be researching and using outside resources be sure to include APA referencing in your posts.
arrow_forward
#bonus3
arrow_forward
Auto Scaling - What Is It?
arrow_forward
Jdbc java program
Note: please do a jdbc example, you can take any scenario it has to contain student names and their information's.
Please provide a clear and big photos of output
arrow_forward
CONVERT TO USE CASE DIAGRAM
arrow_forward
Computer Science
Assume you are a software developer that has written a system that analyses pictures of various recyclable items (such as a can, bottle or a crate). It can be used via a Web Application (Web API), i.e., the users send pictures over the Internet. The system returns for each picture how many of each item are seen in the picture. Discuss if this service should be offered for free. Justify your answer
arrow_forward
Pattern libraries:
1. TGCGATA2. TGTG3. AAAG4. CCTCT5. AAGGGive an overview of the analysis of the aho-Corasick algorithm for running time and memory consumption for 5 sample data patterns?
arrow_forward
TEST II: PROTOTYPING
INSTRUCTION: Create a storyboard that depicts how to fill a car with gas
(petrol) using the tables provided below.
NOTE: Prototyping is a successful and simple way to prototype an
interaction, and is used quite commonly when developing websites. Each
box represents one screen or one element of a task.
Description 1:
Description 2:
Description 3:
Description 4:
Description 5:
Description 6:
arrow_forward
R language
The object created with the command data.frame((c(1,2), c(3,4), c("a","b")) is a(n)
Group of answer choices
1. vector
2. list
3. dataframe
4. matrix
5. array
arrow_forward
When it comes to data encapsulation, what are your thoughts? Elaborate.
arrow_forward
JAVA:
Match each part of the Model-View-Controller design pattern to its description below.
1. Model:
2. View:
3. Controller:
Group of answer choices:
A: Manages and retrieves the programs data.
B: Constructs the presentation for the data. Dose not handle data itself.
C: Handles user input and error. Responsible for passing requests to other parts of the program.
arrow_forward
How does data binding improve the efficiency of data manipulation in graphical user interfaces (GUIs)?
arrow_forward
Write a JSP program to compute the pass percentage and fail percentage in
a class. Assume the results table is stored in the database. Extract the count
of total number of students passed and display the results on the browser.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Related Questions
- Automatic generation of Databases: Python Would anyone have some tips/pointers on writing some code that takes an input file (csv) that contains a number of columns and rows such as Job title, Salary etc. but does not have information such as Name, Address, phone number etc. I have been messing around with the Python Library 'Faker' which has been doing well but I need some advice on making the overal user experience look better. Could someone recommend a good GUI library/package to test with. I love the look of Tableau Dashboards. I would like to be able to display possibly two to six different algorithmic stats to generate the fake data to then be saved in a new output file.A little bit of a strange question I know but any tips greatly appreciated :Darrow_forwardwant accurate answer If answer copied from existing answer from chegg or bartleby I report the answer to support team dont post existing answersarrow_forwardFrames are a type of data structure used in artificial intelligence for representing stereotypical situations. They contain slots that hold values or other frames, and these slots can represent properties or attributes of the situation. What possible properties or attributes would a frame have for an animal such as a 'bird'?arrow_forward
- 6:40 Back Assignment Details Object Oriented Programming Student first_name : string last_name: string id: int gpa : double major: string + set(): void + print(): void Sample Run (User input in bold): Student Information Database First Name: Elaine Last Name: Benes ID: 1961 GPA: 4.0 Major: French_Literature First Name: George Last Name: Costanza ◄ Previous Submit Assignment Dashboard Calendar 7 To Do C Notifications LTE 264 Next ► Inboxarrow_forward2) After a data-mining course the results of the exam was recorded along with some data about the students. The results can be found in in the table below. (GPA is the Grade Point Average.) ID Phone number Language Passed all assignments GPA Passed exam 555 - 3452 555 - 6294 1 Java No 3.1 Yes Java No 2.0 No 3 555 - 9385 C++ Yes 3.5 Yes 4 555 - 9387 Python Yes 2.5 Yes 555 - 9284 555 - 0293 555 - 9237 555 - 3737 Java Yes 3.9 No C++ No 2.9 No 7 Java No 1.9 No 8 Python Yes 3.2 Yes In no more than one page of text, describe the design of a K-Nearest Neighbor classifier to predict which student will fail or pass the exam. b. Use your K-NN classifier to predict if the following student (who has slept too much and missed the main test) will succeed in the retest. а. ID Phone number Language Passed all assignments GPA Passed exam Yes 555 - 6295 C++ 3.0 ?arrow_forwardIn your original post, answer the following: Discuss the following about Libraries: Describe what a Library is, and a programming example where the use of a Library would be beneficial. Because you will be researching and using outside resources be sure to include APA referencing in your posts.arrow_forward
- CONVERT TO USE CASE DIAGRAMarrow_forwardComputer Science Assume you are a software developer that has written a system that analyses pictures of various recyclable items (such as a can, bottle or a crate). It can be used via a Web Application (Web API), i.e., the users send pictures over the Internet. The system returns for each picture how many of each item are seen in the picture. Discuss if this service should be offered for free. Justify your answerarrow_forwardPattern libraries: 1. TGCGATA2. TGTG3. AAAG4. CCTCT5. AAGGGive an overview of the analysis of the aho-Corasick algorithm for running time and memory consumption for 5 sample data patterns?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage