Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Book Icon
Chapter 7.2, Problem 7.9CP
Expert Solution & Answer
Check MarkWant to see the full answer?
Check out a sample textbook solutionBlurred answer
Students have asked these similar questions
Part B - Implement the Queue in LC-3
Now implement a similar circular queue in LC-3 assembly.
Data structure in memory
Use the following layout (similar style to the stack code from class):
Q_BASE
.FILL X4100; base address of queue array
; capacity (in elements)
Q_CAPACITY.BLKW #1
Q_HEAD .BLKW #1
QTAIL .BLKW #1
Q_SIZE .BLKW #1
; index of front element (0..capacity-1)
; index one past last element (0..capacity-1)
; current number of elements (0..capacity)
We will use this calling convention:
ENQUEUE
Input: RO = value to enqueue
Output:
R5 = 1 if success
R5 = 0 if failure (queue full; queue unchanged)
DEQUEUE
Input: none
Output:
If queue not empty:
RO dequeued value
R5 = 1 (success)
If queue empty:
R5 = 0 (failure; queue unchanged; RO don't care)
B1. Subroutine Queuelnit
Write an LC-3 subroutine Queuelnit with this behavior:
Input: RO capacity (number of elements, e.g., 5)
Effects:
Stores capacity into Q CAPACITY
Sets Q HEAD = 0
Sets Q TAIL = 0
Sets Q SIZE = 0
RO should be restored to...
A2. Trace the queue operations
Draft the Queue by hand. Assume we start with an empty queue.
head = 0, tail = 0, size = 0
data = [?, ?, ?, ?, ?] (contents unknown at first)
Trace the following sequence step by step:
enqueue(10)
enqueue(20)
enqueue(30)
dequeue()
enqueue(40)
Part C - Manual LC-3 Trace (Registers + Memory)
In this part, you will simulate your LC-3 queue by hand.
Assume the following initial conditions in memory:
Q_BASE
= x4100
(Q_BASE..Q_BASE+4) are initially unknown (don't care)
Q CAPACITY
= 5
Q_HEAD
= 0
QTAIL
= 0
Q_SIZE = 0
And assume your main program executes this sequence of calls:
RO <- #5 JSR QueueInit RO <- #7 JSR ENQUEUE RO <- #3 JSR ENQUEUE RO <- #9 JSR ENQUEUE JSR DEQUEUE RO <- #5 JSR ENQUEUE JSR DEQUEUE JSR DEQUEUE JSR DEQUEUE ; one extra dequeue
Chapter 7 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Chapter 7.1, Problem 7.1CP Chapter 7.1, Problem 7.2CP Chapter 7.1, Problem 7.3CP Chapter 7.1, Problem 7.4CP Chapter 7.1, Problem 7.5CP Chapter 7.1, Problem 7.6CP Chapter 7.1, Problem 7.7CP Chapter 7.1, Problem 7.8CP Chapter 7.2, Problem 7.9CP Chapter 7.2, Problem 7.10CP
Chapter 7.2, Problem 7.11CP Chapter 7.2, Problem 7.12CP Chapter 7.3, Problem 7.13CP Chapter 7.3, Problem 7.14CP Chapter 7.6, Problem 7.15CP Chapter 7.7, Problem 7.16CP Chapter 7.10, Problem 7.17CP Chapter 7.11, Problem 7.18CP Chapter 7.11, Problem 7.19CP Chapter 7.11, Problem 7.20CP Chapter 7.11, Problem 7.21CP Chapter 7.11, Problem 7.22CP Chapter 7.13, Problem 7.23CP Chapter 7.13, Problem 7.24CP Chapter 7.13, Problem 7.25CP Chapter 7.13, Problem 7.26CP Chapter 7.13, Problem 7.27CP Chapter 7.13, Problem 7.28CP Chapter 7.13, Problem 7.29CP Chapter 7.13, Problem 7.30CP Chapter 7.13, Problem 7.31CP Chapter 7, Problem 1MC Chapter 7, Problem 2MC Chapter 7, Problem 3MC Chapter 7, Problem 4MC Chapter 7, Problem 5MC Chapter 7, Problem 6MC Chapter 7, Problem 7MC Chapter 7, Problem 8MC Chapter 7, Problem 9MC Chapter 7, Problem 10MC Chapter 7, Problem 11MC Chapter 7, Problem 12MC Chapter 7, Problem 13MC Chapter 7, Problem 14TF Chapter 7, Problem 15TF Chapter 7, Problem 16TF Chapter 7, Problem 17TF Chapter 7, Problem 18TF Chapter 7, Problem 19TF Chapter 7, Problem 20TF Chapter 7, Problem 21TF Chapter 7, Problem 22TF Chapter 7, Problem 23TF Chapter 7, Problem 1FTE Chapter 7, Problem 2FTE Chapter 7, Problem 3FTE Chapter 7, Problem 4FTE Chapter 7, Problem 5FTE Chapter 7, Problem 1AW Chapter 7, Problem 2AW Chapter 7, Problem 3AW Chapter 7, Problem 4AW Chapter 7, Problem 5AW Chapter 7, Problem 6AW Chapter 7, Problem 7AW Chapter 7, Problem 8AW Chapter 7, Problem 9AW Chapter 7, Problem 10AW Chapter 7, Problem 11AW Chapter 7, Problem 1SA Chapter 7, Problem 2SA Chapter 7, Problem 3SA Chapter 7, Problem 4SA Chapter 7, Problem 5SA Chapter 7, Problem 6SA Chapter 7, Problem 7SA Chapter 7, Problem 8SA Chapter 7, Problem 9SA Chapter 7, Problem 1PC Chapter 7, Problem 2PC Chapter 7, Problem 3PC Chapter 7, Problem 4PC Chapter 7, Problem 5PC Chapter 7, Problem 6PC Chapter 7, Problem 7PC Chapter 7, Problem 8PC Chapter 7, Problem 9PC Chapter 7, Problem 10PC Chapter 7, Problem 11PC Chapter 7, Problem 12PC Chapter 7, Problem 13PC Chapter 7, Problem 14PC Chapter 7, Problem 15PC Chapter 7, Problem 16PC Chapter 7, Problem 17PC Chapter 7, Problem 18PC Chapter 7, Problem 19PC Chapter 7, Problem 20PC
Knowledge Booster
Background pattern image
Similar questions
- C2. Short explanation In 3-5 sentences: in your own words, with no traces of Al a) Explain how the LC-3 queue behavior you traced in Part C matches the Java-style queue from Part A.arrow_forwardPart A - Queue as a Java-Style Data Structure (this part is on paper) A1. Consider this queue implementation in Java-like pseudocode: final int CAPACITY = 5; int[] data = new int[CAPACITY]; int head = 0; int tail = 0; int size = 0; // index of the front element // index one past the last element // current number of elements // returns true on success, false if full boolean enqueue(int x) {arrow_forwardSelect any text dataset of your own choosing (song lyrics, book excerpt, article, podcast transcript, famous speech, your own writing, etc.). You are to write a program that analyzes the text and produces at least one matplotlib visualization. Requirements: 1. Import text from a .txt file 2. Use string methods to clean and manipulate text (remove punctuation, convert to lowercase, whatever "clean text" means to you) 3. Build dictionaries to count at least 2 things (these are only suggestions): a. Word frequency b. Letter frequency c. Sentence length distribution 4. Use lists to store and process data 5. Include at least 2 functions: a. One void function (e.g., display results) b. One return-value function (e.g., returns a dictionary of word counts) 6. Produce one or more matplotlib graphs: a. Bar chart of top 10 words b. Pie chart of letter usage c. Line graph of sentence lengths Be sure your program is created in the correct format, so the graph is displayed in our online IDE. Failure...arrow_forward
- Unit 7 DQ: Object-Oriented Programming (Graded) Examine the relevance of object-oriented programming. Discuss the benefits of designing Python scripts with an object- oriented first approach. What is meant by object reusability? Develop and demonstrate an everyday example of an object along with its proper attributes. Be sure to provide a thorough analysis of your example and be prepared to evaluate peer examples as well. Your initial post is due no later than 11:59 p.m. EST (Eastern Standard Time) on the second day of the unit. Your initial post should be around 100-125 words in length and should thoughtfully integrate concepts covered in your assigned readings. You are required to respond to at least three of your classmates' posts by 11:59 p.m. EST on the last day of the unit. Responses should be substantive, further the dialogue, and not just be a simple "yes/no", "I agree/disagree", or "nice job". The ideal length of your response should be around 100-125 words. 30 Pointsarrow_forwardI need assistance in the series of questions. If you could please answer 1B part of this please that would be amazing. Thank you so much and if you could be deatiled in the explanation as well as the MatLAB Code if needed! Thank you so mucharrow_forwardI need assistance in the series of questions. If you could please answer 1C part of this please that would be amazing. Thank you so much and if you could be deatiled in the explanation as well as the MatLAB Code if needed! Thank you so mucharrow_forward
- I need assistance in the series of questions. If you could please answer 1A of this please that would be amazing. Thank you so much and if you could be deatiled in the explanation as well as the MatLAB Code if needed! Thank you so mucharrow_forwardYou have learned in class the major steps that occur when a laptop requests a webpage after connecting to a network. In this assignment, you will apply that knowledge to another scenario: opening and playing a YouTube video that resides in Google's data-center infrastructure. Explain, in as much detail as you can, all the steps involved from your device's initial connection to the home/university network, to DNS resolution, routing across multiple networks, reaching Google's servers, and finally receiving the video data. To support your explanation, use tools such as ipconfig, nslookup, and tracert on your own computer, as well as any online IP-lookup tools of your choice. For each stage, include relevant information such as IP addresses, MAC addresses, router hops, and any other details you can gather. You are not expected to find every piece of information, but be as comprehensive as possible based on what you have learned in class, and justify your reasoning with screenshots from...arrow_forwardI need help with this question, please don,t use AI or chatgpt.arrow_forward
- NO USE OF AI PLEASEarrow_forwardMinimum Study Hours per Week per Class Grade 15 A 12 B 9 C 6 D 0 F Application must be menu driven, and contain the following options: A. Determine Hours to Study B. Determine Grade C. Display Averages and Totals D. Quit Note: The user must be able to select any menu option in any order they want. And only exits the application when they choose. Menu option A -- Determine Hours to Study The program will READ in data from a text file named StudyHours.txt. This text file is created by you and will be submitted with your project. Your file must include 5 additional records in addition to the example at the end of this document (10 total). StudyHours.txt contains the following format: First line: Full name Second line: Number of credits Third line: Grade desired for each class The user must correct any bad data in the application. For example, if the file contains a letter grade of 'K', which is not a possible letter grade, they are asked to correct the information. You DO NOT need to...arrow_forwardNO AI USE PLEASEarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTText book imageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageText book imageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Text book imageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Text book imageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningText book imageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr