CSCI 111 Homework 1-8

Ace your homework & exams now with Quizwiz!

If the memory cell whose address is 7 contains the value 10, what is the difference between writing the value 7 into cell number 8 and moving the contents of cell number 7 into cell number 8?

In first case, cell 8 contains value 7; in second case, cell 8 contains value 10

Suppose the following program, written in the machine language of Appendix C, is stored in main memory beginning at address 30 (hexa- decimal). What task will the program perform when executed? 2003 2101 2200 2310 1400 3410 5221 5331 3239 333B B248 B038 C000

It copies the data from the memory cells at addresses 00, 01, and 02 into the memory cells at addresses 10, 11, and 12.

The following are instructions written in the machine language described in Appendix C. Translate them into English. 2BCD

Load the register B with the bit pattern (value) CD.

What is the difference between virtual memory and main memory?

Main memory is memory that is actually present in the machine. Virtual memory is memory whose presence is merely simulated by swapping blocks of data back and forth between a disk.; it is "fictional" memory space.

The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of X copies of Y; that is, 3 times 4 is computed by accumulating the sum of three 4s. Is the program segment correct? Explain your answer. Product = 0 Count = 0 repeat: Product = Product + Y Count = Count + 1 until (Count == X)

No, the algorithm will not always compute the correct answer (specifically when X = 0).

Does the following program represent an algorithm in the strict sense? Why or why not?Count = 0 while (Count != 5): Count = Count + 2

No, the program does not represent an algorithm in the strict sense. The execution of an algorithm must lead to an end. In the program above, the value of Count will never equal 5, thus the program will never terminate.

Can you determine whether the following sentence is true or false? Why? "This sentence is false"

No. If it is true, then it is false; if it is false, then it is true

Suppose three items R, S, and T are placed in a queue in that order. Then one item is removed from the queue before a fourth item, X, is placed in the queue. Then one item is removed from the queue, the items Y and Z are placed in the queue, and then the queue is emptied by removing one item at a time. List all the items in the order in which they were removed.

R, S, T, X, Y, Z

The following are instructions written in the machine language described in Appendix C. Translate them into English A304

Rotate the bit pattern in register 3 one bit to the right 4 times.

Use Euclidean algorithm to find out the Greatest Common Divisor of 36 and 126

STEP 1: According to the Euclidean algorithm, we divide the larger number by the smaller number. 126/36 = 3 with a remainder of 18 STEP 2: The previous divisor (36) then becomes our dividend, and the remainder from the previous equation (18) becomes the divisor. 36/18 = 2 with a remainder of 0 CONCLUSION: The Euclidean algorithm states that when we have a remainder of 0, we are done and the previous remainder is our GCD. In this case, the previous remainder was 18. Thus, the GCD of 36 and 126 is 18.

Using Euclidean algorithm find the greatest common divisor of 66 and 42

STEP 1: According to the Euclidean algorithm, we divide the larger number by the smaller number. 66/42 = 1 with a remainder of 24 STEP 2: The previous divisor (42) then becomes our dividend, and the remainder from the previous equation (24) becomes the divisor. 42/24 = 1 with a remainder of 18 STEP 3: The previous divisor (24) then becomes our dividend, and the remainder from the previous equation (18) becomes the divisor. 24/18 = 1 with a remainder of 6 STEP 4: The previous divisor (18) then becomes our dividend, and the remainder from the previous equation (6) becomes the divisor. 18/6 = 3 with a remainder of 0 CONCLUSION: The Euclidean algorithm states that when we have a remainder of 0, we are done and the previous remainder is our GCD. In this case, the previous remainder was 6. Thus, the GCD of 66 and 42 is 6.

Why is the booting process necessary?

Since most of a computer's main memory is volatile, the operating system must be reloaded each time the machine is turned on.

Design an algorithm that, when given an arrangement of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, rearranges the digits so that the new arrangement represents the next larger value that can be represented by these digits (or reports that no such rearrangement exists if no rearrangement produces a larger value). Thus 5647382901 would produce 5647382910.

Start from the right end of the arrangement of digits and locate the first digit that is smaller than the one to its right. If the aforementioned digit doesn't exist, the arrangement of digits cannot be rearranged to represent a larger value. If the aforementioned digit does exist, call its position in the arrangement the "target position." Swap the aforementioned digit with the smallest digit to its right that is still larger than itself. Arrange the digits to the right of the target position in descending order, from right to left.

Suppose you want to interchange the values stored in memory cells 100 and 200. What is wrong with the following sequence of steps: Step 1. Move the contents of cell number 100 to cell number 200. Step 2. Move the contents of cell number 200 to cell number 100 . Design a sequence of steps that correctly interchanges the contents of these cells. If needed, you may use additional cells.

Step 1. Move the contents of cell number 100 to cell number 300 Step 2. Move the contents of cell number 200 to cell number 100 Step 3. Move the contents of cell number 300 to cell number 200

Translate the following Python program into the machine language described in Appendix C. You may assume that the program begins at address 00, and the x is stored at memory cell whose address is XY. x= 0 while (x < 3): x=x+ 1

Suppose the value of x is stored in the memory cell whose address is XY and the program begins at address 00. 2100 31XY 2003 B110 2201 5112 31XY B006

Translate the high-level statement if (X == 0): Z=Y+ W else: Z=Y+ X into the machine language of Appendix C, assuming that W, X, Y, and Z are all values represented in two's complement notation, each using one byte of memory.

Suppose the values W, X, Y, and Z are stored at locations WW, XX, YY, and ZZ, respectively. Moreover, we use VV as an address. 2000 11XX 12YY B1VV 11WW VV: 5012 30ZZ

What is the difference between syntax and semantics?

Syntax refers to the way something is expressed, whereas semantics refers to what is being expressed.

Identify the body of the following loop structure and count the number of times it will be executed. What happens if the test is changed to read "(Count != 6)"? Count = 1 while (Count != 7): print(Count) Count = Count + 3

The body consists of the indented statements below the while. It will be executed twice. The proposed modification would produce a nonterminating loop.

Describe the client-server model.

The client/server model is a context in which to envision communication between two processes. One process, called the client, makes requests of the other process, called the server. The server process fills the request and returns an appropriate response.

What information is contained in a process table within an operating system?

The status of each process (ready, waiting) and the priority of each process.

Suppose a block of data is stored in the mem- ory cells of the machine described in Appen- dix C from address 98 to A2, inclusive. How many memory cells are in this block? List their addresses.

There are 11 memory cells in this block. Their addresses are: 98, 99, 9A, 9B, 9C, 9D, 9E, 9F, A0, A1, and A2.

A multitasking operating system is an operating system that allows several activities to execute "at the same time."

True

General purpose registers and main memory cells are small data storage cells in a computer.

True

Translate the statement Halfway = Length + Width into the machine language of Appendix C, assuming that Length, Width, and Halfway are all represented in floating-point notation.

We'll represent the addresses of LENGTH, WIDTH, and HALFWAY by XX, YY, and ZZ, respectively. 10XX 11YY 6001 30ZZ

What letters are interrogated by the binary search (Figure 5.14) if it is applied to the list A, B, C, D, E, F, G, H, I, J, K, L, M, N, O when searching for the value J? What about searching for the value Z?

When searching for J: H, L, J When searching for Z: H, L, N, 0

Write the following path: X is a directory containing the subdirectory Y, which contains the subdirectory Z.

X/Y/Z

Simplify the following code segment Y= 5 if (Y == 7 ): Z= 8 else: Z= 9

Y = 5 Z = 9

What is the role of the user interface of an operating system?

handles the communication with the operating system's users.

What is the role of the kernel of an operating system

performs the fundamental tasks of the system.

Write an algorithm to take a positive integer n as input and produce the sum of 1+2+..+n. Your algorithm must use recursive control

recurringSum(n): if (n = 1) return 1 return (n + recurringSum(n - 1))

Write an algorithm to take a positive integer n as input and produce the sum of 1+2+..+n. Your algorithm must use while loop control

sum = 0 i = 1 while (i <= n): sum = sum + i i++ print out (sum)

Suppose the memory cells at addresses 00 through 0D in the machine described in Appendix C contain the following bit patterns: Address Content 00 20 01 04 02 21 03 01 04 40 05 12 06 51 07 12 08 B1 09 0C 0A B0 0B 06 0C C0 0D 00 Assume that the machine starts with its pro- gram counter containing 00. a. What bit pattern will be in register 0 when the machine halt?

04

Suppose the memory cells at addresses 00 through 0D in the machine described in Appendix C contain the following bit patterns: Address Content 00 20 01 04 02 21 03 01 04 40 05 12 06 51 07 12 08 B1 09 0C 0A B0 0B 06 0C C0 0D 00 Assume that the machine starts with its program counter containing 00. What bit pattern will be in register 1 when the machine halts?

04

Suppose the memory cells at addresses 00 through 07 in the machine described in Appendix C contain the following bit patterns: Address 00 2B 01 07 02 3B 03 06 04 C0 05 00 06 00 07 23 List the addresses of the memory cells that are used to hold data

06, 07

Suppose the memory cells at addresses 00 through 0D in the machine described in Appendix C contain the following bit patterns: Address Content 00 20 01 04 02 21 03 01 04 40 05 12 06 51 07 12 08 B1 09 0C 0A B0 0B 06 0C C0 0D 00 Assume that the machine starts with its program counter containing 00. What bit pattern is in the program counter when the machine halts?

0E

Add two binary numbers. The result shall be a binary number. 101.01 + 11.11

1001.00

Convert the following decimal number to binary: 9.625

1001.101

Add two binary numbers in two's complement notation. The result shall be in binary form with four bits: 1101+1110

1011

Write the instruction according to the machine language described in Appendix C Write the op-code of the instruction B2A5 (hexadecimal) as a string of 4 bits

1011

Convert the decimal number into binary: 27

11011

Convert the following number into binary by using two's complement: -35. The result shall be an 8 bits binary number

11011101

Add two binary numbers in two's complement notation. The result is still a four bits binary number 0101+1001

1110

Convert the following number into binary by using two's complement: -28. The result shall be 8 bits binary number.

11100100

Using ASCII code table, find out what is the relationship between the uppercase letter and the corresponding lowercase letter. (Write a number only)

32 or 00100000 or 20h

Use hexadecimal notation to represent the following bit patterns: 0011 1101 0110 1010

3D6A

Encode the following bit patterns using dotted decimal notation: 000001010001001000100011

5.18.35

Convert the binary number to decimal: 101.011

5.375

Suppose a computer contained 512MB (MiB) of main memory, and an operating system needed to create a virtual memory of twice that size using pages of 2KB (KiB). How many pages would be required? (Only write down the number)

524288

Convert a binary number to decimal: 110111

55

How many bits would be in the memory of a computer with 8KB memory? (only write done a number)

64000 or 65536

Suppose the address of an end system on the Internet is quoted as 134.48.4.122. What is the 32-bit address in hexadecimal notation?

8630047A

What is a DNS lookup?

A DNS lookup is the process of using the DNS (Domain Name System) to translate an address from mnemonic form into the corresponding IP address.

What is the difference between a formal programming language and a pseudocode?

A formal programming language has a specific syntax and you must adhere to the "grammar rules" of that language. Pseudocode is less formal than a programming language. It is used during the algorithm development process to gather and express ideas.

How does a hub differ from a repeater?

A hub connects individual computers to form a bus network, whereas a repeater connects two bus networks to form a larger network.

What is the difference between a process that is ready and a process that is waiting?

A process that is ready could make progress if given a time slice, but giving a time slice to a process that is waiting would merely waste time since it cannot progress until some event occurs.

What is a proxy server and what are its benefits?

A proxy server is an intermediary between a client and a server that shields the client from inappropriate behavior of the server.

How does a router differ from such devices as repeaters, bridges, and switches?

A router connects two networks to form an internet, whereas the other devices connect networks to form a larger network.

Design a set of syntax diagrams that describes the grammatical structure of "sentences" that consist of occurrences of the word yes followed by the same number of the word no. For example, "yes yes no no" would be such a sentence, whereas "no yes," "yes no no," and "yes no yes" would not.

A string would have the structure of "yes no," or the word yes followed by a "sentence" followed by the word no.

Summarize the distinction between a translator and an interpreter

A translator merely converts a program form one language to another. An interpreter executes the source program without producing a translated copy.

Summarize the distinction between a machine language and an assembly language.

An assembly language is essentially a mnemonic form of a machine language.

What is the distinction between a network and an internet?

An internet is a collection of networks that have been linked so that messages can be transferred form one network to another. In an internet, each computer has two addresses associated with it. One is the computer's network address; the other is the computer's internet address. Each network within an internet maintains its own internal characteristics, which may not be the same as those in the other networks.

Four prospectors with only one lantern must walk through a mine shaft. At most, two prospectors can travel together and any prospector in the shaft must be with the lantern. The prospectors, named Andrews, Blake, Johnson, and Kelly, can walk through the shaft in one minute, two minutes, four minutes, and eight minutes, respectively. When two walk together they travel at the speed of the slower prospector. How can all four prospectors get through the mine shaft in only 15 minutes? After you have solved this problem, explain how you got your foot in the door.

Andrews and Blake go through the shaft first (2 minutes), and Andrews returns with the lantern (1 minute). Then, Johnson and Kelly go through (8 minutes), and Blake returns with the lantern (2 minutes). Finally, Andrews and Blake go through again (2 minutes). The total travel time is 2 + 1 + 8 + 2 + 2 = 15 minutes.

Suppose you wanted to establish a firewall to filter out email messages containing certain terms and phrases. Would this firewall be placed at your domain's gateway or at the domain's mail server? Explain your answer.

At the domain's mail server because the gateway is only a router and therefore "sees" only individual packets rather than the content of entire messages.

Translate the following instructions from English into the machine language described in Appendix C JUMP to the instruction at memory location 24 if the contents of register 0 equals the value in register A.

BA24

Use hexadecimal notation to represent the following bit pattern: 1011 1111 0101 0010

BF52

If a computer's mnemonic Internet address is batman.batcave.metropolis.gov what might you conjecture about the structure of the domain containing the machine?

Based upon the example given on pg. 198 in the textbook, I believe that we can assume that an individual computer named batman, is in the subdomain named batcave, within the domain metropolis, within the TLD .gov .

Summarize the distinction between batch processing and interactive processing.

Batch processing is the execution of jobs by collecting them in a single batch, then executing them without further interaction with the user. The downside of batch processing is that the user has no interaction with their jobs once they are submitted to the operator.On the other hand, interactive processing is "real-time processing" that allows a program being executed to carry on a dialogue with the user through remote terminals.

What is the difference between embedded systems and PCs?

Embedded systems are typically dedicated to specific tasks, whereas PCs are general purpose computer systems capable of many different tasks. Embedded systems are often characterized by more limited resources, stricter deadlines, and narrower channels for human interaction than PCs.

List in chronological order the major events that take place when a process is interrupted.

First: Interrupt signal occurs. Second: Machine completes its current instruction. Third: Machine saves the current program state. Fourth: Machine begins executing the interrupt routine.

What bit patterns are represented by the following hexadecimal patterns? 5F7D93

0101 1111 0111 1101 1001 0011

Translate: "Work hard!" by using ASCII code

01010111 01101111 01110010 01101011 00100000 01101000 01100001 01110010 01100100 00100001

What bit patterns are represented by the following hexadecimal patterns? 6EA08C

0110 1110 1010 0000 1000 1100

Write the instruction according to the machine language described in Appendix C Write the operand field of the instruction B2A5 (hexadecimal) as a string of 12 bits.

001010100101

Convert the following two's complement representation into decimal 11010

-6

Suppose the memory cells at addresses 00 through 07 in the machine described in Appendix C contain the following bit patterns: Address 00 2B 01 07 02 3B 03 06 04 C0 05 00 06 00 07 23 List the addresses of the memory cells that contain the program that will be executed if we start the machine with its program counter containing 00.

00, 01, 02, 03, 04, 05

What bit pattern is represented by the following dotted decimal patterns? 8.12.20.13

00001000 00001100 00010100 00001101

Write the instruction according to the machine language described in Appendix C Write the instruction 2304 (hexadecimal) as a string of 16 bits.

0010001100000100

List four activities of a typical operating system.

1. Control data and its access 2. provide for efficient device access 3. coordinate the use of the machine's resources 4. control access to the machine.

Write a set of directions that tells an operating system's dispatcher what to do when a process's time slice is over.

1. Save the current process' state 2. Select another process from the process table 3. Load that process' state 4. Start the next time slice

Convert the following two's complement representation into decimal: 01101

13

Suppose a machine language is designed with an op-code field of 4 bits. How many different instruction types can the language contain?

16

Translate the following instructions from English into the machine language described in Appendix C LOAD register 6 with the hexadecimal value 77.

2677

Give a real life example that the abstraction is applied. i.e. we use things without known the internal structure of the thing.

Abstraction allows us to ignore the internal details of a complex device and use the device as a single comprehensible unit. There are many things that we use in our everyday life, yet we don't necessarily know or understand how they work (i.e. the underlying structure and components). This is abstraction. We are able to comprehend "the abstract tool" that is relevant to the task at hand, without having to know much about the tool's internal details. A real life example of abstraction is the smartphone. Nearly everyone in modern society has one and it seems like smartphones are rapidly evolving to do more and more tasks. Despite the increasing complexity of smartphones, it is not necessary for users to understand much beyond what buttons to press and where to tap on the screen to get the phone to do what you want. Thus, we are able to use our phones as abstract tools without getting lost in the details of the phone's software or the networks that connect our phones to other phones.

In an object-oriented programming environment, how are types and classes similar? How are they different?

Both types and classes are templates used to describe the underlying composition of "variables." Types, however, are predefined whereas classes are defined by the programmer within the "written program." (We put written program in quotes because the class definition could be imported from a pre-written package as in Java's API.)

What is the value of the program counter in the machine described in Appendix C immediately after executing the instruction B0CD?

CD

General purpose registers are inside the ______________; main memory cells are outside the ____________.

CPU

describe three kind of distributed computing system

Cluster computing system - a distributed system in which many independent computers work closely together to provide computation or services comparable to a much larger machine. Grid computing system - distributed systems that are more loosely coupled than clusters but that still work together to accomplish large tasks. Cloud computing system - a distributed system in which huge pools of shared computers on the network can be allocated for use by clients as needed

Rewrite the following program segment using a while structure rather than a repeat structure. Be sure the new version prints the same values as the original. Count = 1 repeat: print(Count) Count = Count + 1 until (Count >= 7)

Count = 1 while (Count <= 6): print(Count) Count = Count + 1

Rewrite the following program segment using a repeat structure rather than a while structure. Be sure the new version prints the same values as the original. Count = 2 while (Count < 7): print(Count) Count = Count + 1

Count = 2 repeat: print(Count) Count = Count + 1 until (Count >= 7)

Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorithm should report the values 1, 2, 3, 4, 6, and 12.

If we know that n is a positive integer, then the following algorithm would find all the factors of n: x = 1 while (x <= n): if (x divides n): print(x) x = x + 1

Name and describe four different programming paradigms.

Imperative paradigm: Programs consist of a sequence of commands. Object-oriented paradigm: Programs are organized as active elements called objects. Functional paradigm: Programs consist of nested functions. Declarative paradigm: Programs consist of declarative statements that describe properties.

What is a protocol? Identify three protocols introduced in this chapter and describe the purpose of each.

Protocol is the set of rules that governs network activity/communication. Three types of protocols introduced in this chapter are: CSMA/CD - its purpose is to detect that its message transmissions are colliding with each other. This protocol requires a pause before reattempting to transmit. CSMA/CA - its purpose is to avoid the collision of message transmissions, rather than detect them. This protocol requires that machines undergo a waiting period and then transmit messages in the order that they have been waiting. HTTP - its purpose is to allow users to communicate data on the World Wide Web. Hypertext documents are normally transferred between browsers and web servers using HTTP.

Summarize the principles of public-key encryption.

Public-key encryption is a system by which messages can be encrypted using a publicly known encoding key but deciphered only by using a private decoding key.

What is the hidden terminal problem? Describe a technique for solving it.

The hidden terminal problem is that machines in a wireless network may not be able to hear each other's transmissions. One approach to solving the problem is to have each machine send a short request to the AP and wait to receive an acknowledgement before transmitting an entire message. All machines will be able to hear the acknowledgement.

Classify the following instructions (in the machine language of Appendix C) in terms of whether its execution changes the contents of the memory cell at location 3B, retrieves the contents of the memory cell at location 3C, or is independent of the contents of the memory cell at location 3C. 253C

The instructions are independent of the contents of the memory cell at location 3C.

Classify the following instructions (in the machine language of Appendix C) in terms of whether its execution changes the contents of the memory cell at location 3B, retrieves the contents of the memory cell at location 3C, or is independent of the contents of the memory cell at location 3C. 153C

The instructions retrieve the contents of the memory cell at location 3C.

What is the difference between an open network and a closed network?

The internal details of an open network are public knowledge and can be used without specific permission from an owner, which allows different organizations to produce compatible products. Such details of a closed network are proprietary, which restricts the ability of organizations to produce their own versions of the network's components.

In what sense do the following three steps not constitute an algorithm?Step 1: Draw a straight line segment between the points with rectangular coordinates (2,5) and (6,11). Step 2: Draw a straight line segment between the points with rectangular coordinates (1,3) and (3,6). Step 3: Draw a circle whose center is at the intersection of the previous line segments and whose radius is two

The lines in Step 1 and Step 2 do not intersect. Thus, it is not possible to draw a circle at their intersection as instructed in Step 3. An algorithm must consist of executable steps. Step 3 is not executable, thus the three steps do not consitute an algorithm.

Describe the peer-to-peer model.

The peer-to-peer model is a context in which to envision communication between two processes. Unlike the client/server model, a process under the peer-to-peer model may provide a service to and receive service from another process.

What information is contained in the state of a process?

The process state contains the current status of the activity (activity = execution of a program); includes the current position in the program being executed (the value of the program counter) as well as the values in the other CPU registers and the associated memory cells.


Related study sets

MedSurg2 Final Exam Practice Questions

View Set

Levels of Organization of Muscle Fiber

View Set

Ch 19. - The Arts of Asia: India, China, and Japan

View Set

PSYC 305 Developmental Psychology

View Set

Chapter 7The above cumulative recorder output is most likely the result of behavior being reinforced on a(n) _______________ schedule.

View Set