0% found this document useful (0 votes)
10 views

Introduction To Computer System

ICS

Uploaded by

Min Khant Kyaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
10 views

Introduction To Computer System

ICS

Uploaded by

Min Khant Kyaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 11
Chapter 5 41, Summarize the distinctions between a process, an algorithm, and a program. Solution- A process is the activity of executing an algorithm. A program is a representation of an algorithm. 2. The Euclidean algorithm finds the greatest common divisor of two positive integers X and Y by the following process: As long as the value of neither X nor Y is zero, continue dividing the larger of the values by the smaller and assigning X and Y the values of the divisor and remainder, respectively. (The final value of X is the greatest common divisor.) Express this algorithm in our pseudocode. Solution- X < the larger input; Y < the smaller input; while (Y not zero) do (Remainder — remainder after dividing X by Y; X TestEntry and there remain entries to be considered) do (Select the next entry in List as TestEntry.); if CTargetValue = TestEntry) hen (Declare search a success.) Ise (Declare search a failure.) dend if . Describe the Components of repetitive control. Solution- Components of repetitive control Initialize: Establish an initial state that will be modified toward the termination condition Test: Compare the current state to the termination condition and terminate the repetition if equal Modify: Change the state in such a way that it moves toward the termination condition . (a) Write down the insertion sort algorithm expressed in pseudocode. Solution- ‘The insertion sort algorithm expressed in pseudocode procedure Sort (List) Ne? while (the value of N does not exceed the length of List) do (Select the Nth entry in List as the pivot entry; Move the pivot entry to a temporary location leaving a hole in List; while (there is a name above the hole and that name is greater than the pivot) do (move the name above the hole down into the hole leaving a hole above the name) Move the pivot entry into the hole in List; NeN+I ) 6. (b)Suppose the insertion sort as presented in Figure was applied to the list Gene, Cheryl, Alice, and Brenda. Describe the organization of the list at the end of each execution of the body of the outer while structure. Solution- Cheryl Alice Alice Gene Cheryl Brenda Alice Gene Cheryl Brenda Brenda_— Gene 7. Convert the pseudocode routine LA-0; Xe while (X <6) do (L-L+X; X<—X+1) to an equivalent routine using a repeat statement. Solution- Z—0; Xo repeat (Z<—Z X: X#X 1) until (X 6) 8. (a)Write down the binary search algorithm in pseudocode. Solution- The binary search algorithm in pseudocode procedure Search (List, TargetValue) if (List empty) then (Report that the search failed.) else [Select the “middle” entry in List to be the TestEntry; Execute the block of instructions below that is associated with the appropriate case. case 1: TargetValue = TestEntry (Report that the search succeeded.) case 2: TargetValue < TestEntry (Apply the procedure Search to see if TargetValue is in the portion of the List preceding TestEntry, and report the result of that search.) case 3: TargetValue > TestEntry (Apply the procedure Search to see if TargetValue is in the portion of List following TestEntry, and report the result of that search.) lend if 9. (b)What names are interrogated by the binary search Figure when searching for the name Joe in the list Alice, Brenda, Carol, Duane, Evelyn, Fred, George, Henry, Irene, Joe, Karl, Larry, Mary, Nancy, and Oliver? Solution- The first name considered would be Henry, the next would be Larry, and the last would be Joe. 10, What sequence of numbers would be printed by the following recursive procedure if we started it with N assigned the value 1? Solution- procedure Exercise (N) print the value of N; if (N <3) then (apply the procedure Exercise to the value N+ 1); print the value of N. 1, 2, 3, 3, 2,1 Chaper 6 1. Draw “the composition of a typical imperative program or program unit”. Solution- The composition of a typical imperative program or program unit Program The first part consists of declaration statements describing the data that is ‘manipulated by the program. The second part consists of imperative statements describing the action to 2. Displays the conceptual structure declared by the statement int Scores{1][3]; in the language C. Solution- A two-dimensional array with two rows and nine columns ‘Scores Scores [1] [3] inC and its derivatives where indices start at zero. 3. Draw the for loop structure and its representation in C++, CA, and Java Solution- ‘The for loop structure and its representation in C++, Ci, and Java False True for (int Count = 1; Count < 4; Count+s) boay + |. What is the difference between a declarative statement and an imperative statement? Solution- ‘A declarative statement describes terminology; an imperative statement describes steps in an algorithm. List some common data types. Solution- Integer, real, character, and Boolean . What is the difference between an array and an aggregate type? Solution- All components of an array have the same type. What is the difference between a formal parameter and an actual parameter? Solution- A formal parameter is an identifier within a procedure. It serves as a place- holder for the value, the actual parameter, that is passed to the procedure when the procedure is called, . Draw the translation process. Solution- ‘The translation process 9. Describe the three major steps in the translation process. Solution- Lexical analysis: the process of identifying tokens. Parsing: the process of recognizing the grammatical structure of the program. Code generation: the process of producing the instructions in the object program 10, Draw A syntax diagram of our if-then-else pseudocode statement, Solution- 11, Draw the parse tree for the expression “x y x 2”. Solution- Express orm + Exprossion | Factor] x [Term Term | + [Expression = Factor Factor Torm y x Factor Chapter 7 1, How does the development stage of the software life eyele affect the maintenance stage? Solution- Small efforts made duri ing maintenan development can pay enormous dividends dur- 2, Summarize each of the four stages (requirements analysis, design, implementation, and testing) within the development phase of the software life cycle. Solution- The requirements analysis phase concentrates on what the proposed sys- tem must accomplish, ‘The design phase concentrates on how the system accomplishes its goals. TThe implementation phase concentrates on the actual construction of the system. The testing phase concentrates on making sure that the system does what it is intended to do, 3. What is the role of a software requirements specification? Solution- A software requirements specification is a written agreement between a client and a software engineering firm stating the requirements and specifi- cations of the software to be developed 4, Summarize the distinction between the traditional waterfall model of software development and the newer incremental and iterative paradigms. Solution- ‘The traditional waterfall approach dictates that the requirements analysis, design, implementation, and testing phases be performed in a linear manner. The newer models allow for a more relaxed trial-and-error approach. 5. What is the distinction between traditional evolutionary prototyping and open-source development? Solution- Traditional evolutionary prototyping is performed within the organization developing the software, whereas open-source development is not restricted toan organization. In the case of open-source development the person over- seeing the development does not necessarily determine what enhance- ‘ments will be reported, whereas in the case of traditional evolutionary prototyping the person managing the software development assigns person- nal to specific enhancement tasks. Chapter 8 « Give examples ( outside of computer science ) of each of the following structures: list, stack, queue and tree. Solution- List: A listing of the members of a sports team. Stack: The stack of trays in a cafeteria. Queue: The line at a cafeteria, ‘Tree: The organization chart of many governments. . Summarize the distinction between lists, stacks, and queues. Solution- Stacks and queues can be thought of as special types of lists. In the case of a general list, entries can be inserted and removed at any location. In the case of a stack, entries can be inserted and removed only at the head. In the case of a queue, entries can be inserted only at the tail, and entries canbe removed only at the head. . Suppose the letter A is pushed onto an empty stack, followed by the letters B and , in that order. Then suppose that a letter is popped off the stack and the letters D and E are pushed on. List the letters that would be on the stack in the order they would appear from top to bottom. Ifa letter is popped off the stack, which letter will be retrieved? Solution- ‘The letters on the stack from top to bottom would be E, D, B, and A. Ifa letter were popped off the stack, it would be the letter E. . Suppose the letter A is placed in an empty queue, followed by the letters B and C, in that order, Then suppose that a letter is removed from the queue and the letters D and E are inserted. List the letters that would be in the queue in the order they would appear from head to tail, Ifa letter is now removed from the queue, which letter will it be? Solution- The letters in the queue from head to tail would be B, C, D, and E. If a letter were removed from the queue, it would be the letter B. . Suppose a tree has four nodes A, B, C, and D. If A and C are siblings and D's parent is A, which nodes are leaf nodes? Which node is the root? Solution- J \ Cc D The leaf (or terminal) nodes are D and C. B must be the root node because all the other nodes have parents. 6. Show how the array below would be arranged in main memory when stored in row major order. Solution- 537428196 7. Give a formula for finding the entry in the ith row and jth column of a two-dimensional array if itis stored in column major order rather than row major order. Solution- IER is the number of rows in the matrix, the formula is R(J - 1) + (I- 1). 8. Draw a diagram representing how the tree below appears in memory when stored using the left and right child pointers, as described in this, section. Then, draw another diagram showing how the tree would appear in contiguous storage using the alternative storage system described in this section. Solution- Root pointer z [Nt [NL NIL | NIL 9. Draw pictures showing how the array below appears in a machine’s memory when stored in row major order and in column major order: alel/clo ej|ri|ao|H Plat «fe Solution- A.ELBE.C.G,K,D,H,L

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy