Question 1

380
1.The word modem is derived from what two words? MODULATE - DEMODULATE or MODULATOR - DEMODULATOR 2. What is the binary representation of 15.5 base 10? ANSWER: 1111.1. 3.What is the octal representation of 19 decimal? ANSWER: 23 BASE 8 or 23 4. What is the binary representation of 65 octal? ANSWER: 110101. 5. What is the octal representation of A5 hexadecimal? ANSWER: 245. 6. What is the octal sum of 064321 octal and 016477 octal? ANSWER: 103020. 7. Multiple Choice: Which of the following reads a source program one statement at a time and causes the execution of that statement? w) assembler, x) compiler y) lister z) interpreter ANSWER: Z -- INTERPRETER

Transcript of Question 1

Page 1: Question 1

1.The word modem is derived from what two words?MODULATE - DEMODULATE or MODULATOR -

DEMODULATOR

2. What is the binary representation of 15.5 base 10?ANSWER: 1111.1.3.What is the octal representation of 19 decimal?ANSWER: 23 BASE 8 or 234. What is the binary representation of 65 octal?ANSWER: 110101.5. What is the octal representation of A5 hexadecimal?ANSWER: 245.6. What is the octal sum of 064321 octal and 016477 octal?ANSWER: 103020.7. Multiple Choice: Which of the following reads a source program one statement at atime and causes the execution of that statement?w) assembler, x) compiler y) lister z) interpreterANSWER: Z -- INTERPRETER

Page 2: Question 1

8. Suppose that a byte is 8 bits. If one character is represented by onebyte of storage, then how many different characters could be represented using one byte percharacter ANSWER: 28 or 2569. If b=5, c=4, d=2, and e=3 and all are integer variables, what integervalue is obtained for the following expression when programming in BASIC?b + c*d**e (read: B plus C star D star star E)ANSWER: 37.

10.Subtract in base 2: 1011 - 110ANSWER: 101.11. Place the following computer languages in order from the lowest level (i.e., most primitive and most hardware dependent) to the highest level(i.e.,least primitive and least hardware dependent):microcode, BASIC, assembler-language, machine language.ANSWER: MICROCODE, MACHINE-LANGUAGE, ASSEMBLER-LANGUAGE, BASIC.12. Place the following programming languages in chronological orderwith regard to their first introduction to the computing public: BASIC, ALGOL, Pascal, FORTRANANSWER: FORTRAN, ALGOL, BASIC, PASCAL

Page 3: Question 1

13.What is the largest positive decimal value which can be represented bysix binary digits (bits)? ANSWER: 63.• 14. Which of the following terms refers to the use of a computer to• create, store, revise, and produce text:• w) teleprocessing• x) word-processing• y) time-sharing• z) voice-synthesis• ANSWER: X -- WORD-PROCESSING.

• 15. A computer program can be written to play tic-tac-toe in a manner• such that the program never loses the same game situation more

than one time. In which of the• following areas of computer science would this program be of

interest:• w) operating systems• x) computability• y) artificial intelligence• z) optimization• ANSWER: Y -- ARTIFICIAL INTELLIGENCE

Page 4: Question 1

16. Which of the following computers would implement the method of processing in which one operation is completed before the next operation is initiated?

w) analogx) digitaly) asynchronousz) synchronousANSWER: Y – ASYNCHRONOUS.17. Which of the following computers represents variables by physicalanalogies?w) analogx) digitaly) asynchronousz) synchronousANSWER: W – ANALOG.18. What is the process of filling internal storage of a computer withinformation from auxiliary or external storage?w) compilex) linky) loadz) assembleANSWER: Y -- LOAD

Page 5: Question 1

19. The algebra concerned with two-state variables was named forwhich of the following persons?w) George Boolex) Blaise Pascaly) Issac Newtonz) Albert EinsteinANSWER: W -- GEORGE BOOLE.20. Place the following in order from the smallest unit of memory to thelargest: block, byte, bit, wordANSWER: BIT, BYTE, WORD, BLOCK.21. Which of the following is characteristic of the first generation ofdigital computers?w) vacuum tubesx) transistorsy) semi-conductorsz) chipsANSWER: W -- VACUUM TUBES.22. What are the 4 major divisions in a COBOL program?ANSWER: IDENTIFICATION, ENVIRONMENT, DATA, PROCEDURE.23. What are graphs of mathematical sets called?ANSWER: VENN DIAGRAMS

Page 6: Question 1

24. Of the following men, who co-authored the first book on

programming?

w) Maurice V. Wilkes

x) John von Neumann

y) Thomas J. Watson

z) J. Presper Eckert

ANSWER: W -- MAURICE V. WILKES.

25The CPU consists of what two units:

ANSWER: ARITHMETIC/LOGIC UNIT and CONTROL UNIT.

26. What is the material from which most micro-electronic chips are made?

ANSWER: SILICON.

27. How many nibbles are in a byte?

ANSWER: TWO.

28. What is the 10's complement of 45?

ANSWER: 55

Page 7: Question 1

29.A COBOL source program has 4 divisions. Which of the followingdivisions contains the equipment configuration?w) Identificationx) Environmenty) Dataz) ProcedureANSWER: X -- ENVIRONMENT30.What is the radix of an octal number?ANSWER: 831. Which of the following is NOT characteristic of an operating system.An operating system:w) is a resource managerx) is a library of utility programsy) defines the "user interface"z) shares the hardware among usersANSWER: X -- IS A LIBRARY OF UTILITY PROGRAMS.32. The offsetting of the tremendous variation in I/O speeds for variousdevices by the use of a device of intermediate speed is known as:w) unbundlingx) channelingy) spoolingz) loadingANSWER: Y -- SPOOLING

Page 8: Question 1

33. The name given to a special-purpose computer devoted to handlingI/O independently of the main processor of the computer system is:w) loaderx) channely) trackz) bundlerANSWER: X – CHANNEL.34. Which of the following techniques is a hardware technique used inhigh performance computer systems to exploit certain types of parallelism in instructionprocessing?w) pipeliningx) networkingy) multiprocessingz) multitaskingANSWER: W – PIPELINING.35.In the CPU, the "instruction register" holds the instruction which:w) was previously executedx) is CURRENTLY being executedy) is the next instruction to be executedz) contains no instruction information.ANSWER: X -- IS CURRENTLY BEING EXECUTED

Page 9: Question 1

36. Second generation computers replaced vacuum tubes with whatelectronic device?ANSWER: TRANSISTOR.37. What is the ones complement of the following 4-bit string: 1101ANSWER: 0010.38. Determine the two's complement of the following 4 bit string: 0010ANSWER: 1110.39. What does the acronym LISP stand for?ANSWER: LIST PROCESSING.40. What is the only data structure in the programming language LISP?ANSWER: A LIST.41. The floppy diskette is used as an external storage device by mostmicrocomputers. In a single-sided, double-density 5-and 1/4 inch diskette, storage locationsconsist of 40 narrow concentric ring-shaped areas. What is the standard term for the 40 ring-shaped areas?ANSWER: TRACKS

Page 10: Question 1

42.Identify the oldest known mechanical computing aid and the countryin which it was used as early as the 6th century B.C.ANSWER: ABACUS and CHINA.43. Give the value of the largest integer that can be written as an 8-bitbinary number.ANSWER: 255 or 2 TO THE 8th POWER, MINUS 1.44. The data-transfer rate through a modem is often described in terms ofthis four-letter name. Give me this name.ANSWER: BAUD.45. The most common type of computer disk records its information bywhat type of process?w) electricalx) opticaly) magneticz) mechanicalANSWER: Y – MAGNETIC.46. You are transmitting information at 300 baud. This means you aresending approximately:w) 300 bytes per secondx) 300 kilobytes per minutey) 300 bits per secondz) 300 bits per minute(pron: the au in baud is pronounced like the a in raw, bytes is pronounced like bites)ANSWER: Y -- 300 BITS PER SECOND

Page 11: Question 1

47.Which of the following is not considered hardware?w) floppy diskx) RAM (pron: as a word "ram")y) linkerz) modemANSWER: Y – LINKER.48. MS-DOS, UNIX and OS/2 are:(pron: "M S dos" (rhymes with moss), "U nix", "O S two")w) types of computersx) graphics programsy) programming languagesz) operating systemsANSWER: Z -- OPERATING SYSTEMS.49. What are lines of computer code that are transmitted to yourcomputer without your knowledge and are capable of such things as slowing down youroperations, filling up memory space and distorting your programs called?ANSWER: VIRUSES (OR VIRUS) or WORMS or TROJAN HORSE.50. You are programming in BASIC on your PC. What statement shouldbe the last line of your program?ANSWER: END

Page 12: Question 1

51.A parity check can be used to check for:w) programming logic errorsx) divisions by zeroy) undefined variablesz) internal computer errorsANSWER: Z -- INTERNAL COMPUTER ERRORS52. In an EVEN parity system, what is the value of the parity bitassociated with an 8 bit character if the number of 1 bits is 4?ANSWER: 0.53. The primary electronic elements used in the first computers werevacuum tubes. What were the primary electronic elements in the next generation of computers?w) magnetic disksx) integrated circuitsy) multiplexorsz) transistorsANSWER: Z – TRANSISTORS.54. What decimal number does the hexadecimal number 1E represent?ANSWER: 30.55. The inventor of the tabulating machine which read data frompunched cards and was used in the 1890 census wasw) Thomas Edison x) Herman Hollerith y) Blaise Pascal (pron: blez - pas - kal')z) John von NeumannANSWER: X -- HERMAN HOLLERITH

Page 13: Question 1

56.A cache (pron: cash) is:w) a low speed buffer memoryx) a high speed buffer memoryy) ROMz) a registerANSWER: X -- A HIGH SPEED BUFFER MEMORY.57. RS-232C (pron: R S two thirty two Y) refers to a type of:w) personal computerx) physical interface between a computer and peripheral equipmenty) printerz) monitorANSWER: X -- PHYSICAL INTERFACE BETWEEN A COMPUTER ANDPERIPHERAL.58. How much is 1A (Hex) plus 2B (Hex)?ANSWER: 45 (Hex) or 69 (Decimal.59. What is the binary result when 0111 binary is subtracted from 1000binary?ANSWER: 0001 (Base 2.60. Which of the following would be used to find syntax errors in aPascal program?w) assemblerx) compilery) error trapz) all of the aboveANSWER: X -- COMPILER

Page 14: Question 1

61.What company created the 80X86 family of microprocessors?ANSWER: INTEL.62. Ada Augusta, also known as the Countess of Lovelace, is generallyconsidered to be the first programmer of a stored-program computer. Who was her famousfather?w) John Smithx) Lord Byrony) John von Neumannz) Eli WhitneyANSWER: X -- LORD BYRON, THE POET.63. How many memory locations can be accessed with a 5-bit addressbus?ANSWER: (2 to the 5th power) or 32.64. What type of graphics card offers the greatest resolution?w) VGAx) EGAy) SVGAz) CGAANSWER: Y – SVGA.65. If A = 1011 (base 2) and B = 1101 (base 2), what is A bitwise or'dwith B?ANSWER: 1111

Page 15: Question 1

66.Which of the following is a last-in, first-out (also called LIFO) datastructure:w) treex) stacky) queuez) listANSWER: X – STACK.67. Complete the following analogy: LIFO is to stack as FIFO is to:ANSWER: QUEUE.68. Which of the following operations is used on a stack:w) popx) enqueuey) insertz) deleteANSWER: W – POP.69. Arrange the following THREE processes in their order of operation:load, compile, linkANSWER: COMPILE then LINK then LOAD.70. A typical hard disk is divided into tracks and what?ANSWER: SECTORS.71. What are the TWO wild card indicators in DOS?ANSWER: ASTERISK AND QUESTION MARK or STAR AND QUESTIONMARK

Page 16: Question 1

72. What happens on a DOS machine when you simultaneously holddown the <Ctrl> <Alt> and <Del> (read: control, alternate and delete) keys?ANSWER: THE SYSTEM WILL REBOOT, RESET OR RESTART.73. The ls (pron: L - S) command in Unix is similar to what command in DOS?ANSWER: DIR.74. Which of the following does NOT belong?w) starx) ringy) addressz) busANSWER: Y – ADDRESS.75. What batch file, if present in the root directory, is automaticallyexecuted by DOS after booting?ANSWER: AUTOEXEC.BAT.76. The statement: C := A + B; is the correct syntax in all but one ofthe following languages:w) Pascalx) Coboly) Adaz) Modula - 2ANSWER: X -- COBOL

Page 17: Question 1

77.Assignment is performed with the equal sign in all but one of thefollowing languages:w) Fortranx) Basicy) Pascalz) CANSWER: Y – PASCAL.78. What is the value of the parity bit produced by an even parity check onan 8-byte word if the number of 1's is 7?ANSWER: 1.79. What parity bit should be appended to 1011 to generate even parity?ANSWER: 1.80. What is the value of the parity bit produced by an odd parity check if the number of 1's in an 8 bit machine word is 6?ANSWER: 181. An accumulator is a special type of:w) bitx) registery) bytez) pageANSWER: X -- REGISTER

Page 18: Question 1

82.What is the radix of a hexadecimal number?ANSWER: 1683. Every Pascal program begins with what reserved word?ANSWER: PROGRAM.84. The dir command in DOS is similar to what command in Unix?ANSWER: 1s85. The CAT (read: C - A - T) command in Unix is similar to what command in DOS?ANSWER: TYPE86. What three colors are used to generate all of the colors on a color monitor?ANSWER: RED, BLUE, GREEN87. The hexidecimal equivalent of the decimal number 23 is:w) 18x) 19y) 32z) 17ANSWER: Z – 1788. Which of the following is NOT a legitimate data structure?w) Listx) Queuey) Registerz) GraphANSWER: Y -- REGISTER

Page 19: Question 1

89.Seven is a prime number. Express seven as a three-bit binary number.ANSWER: 11190. The person who conceived and designed a "difference engine" butwas not able to build it was:w) Herman Hollerithx) Charles Babbagey) Blaise Pascalz) Thomas EdisonANSWER: X -- CHARLES BABBAGE91. Which of the following is NOT a sorting algorithm.w) Heapx) Bubbley) Binaryz) InsertionANSWER: Y – BINARY92. Which of the following was the first digital computer?w) Univacx) Illiacy) VAX II/780z) EniacANSWER: W -- UNIVAC

Page 20: Question 1

93.Which of the following is NOT a looping construct?w) Do...Whilex) If...Then...Elsey) For...Doz) Repeat...UntilANSWER: X -- IF...THEN...ELSE.94. Herman Hollerithw) was the father of the computerx) developed a coding system for punching cards which is still in use todayy) invented a mechanical calculator that worked like an odometerz) built the first electronic computerANSWER: X -- DEVELOPED A CODING SYSTEM FOR PUNCHING CARDS95. The code that uses only "1"s and "0"s to represent numbers is the:w) decimalx) binaryy) alphanumericz) floating pointANSWER: X – BINARY96. How many bytes is 1 kilobyte?ANSWER: 1,024 BYTES97. If a Manchester encoded transmission system requires a data rate of 100 Mbps, what minimum channel bandwidth is required?ANSWER: 200 MEGAHERTZ

Page 21: Question 1

98.If you needed an Analog to Digital converter that would adequatelyencode in the range of -5 to +5 volts with a resolution of 500 microvolt, what minimum numberof bits resolution would be required:w) 13 bitsx) 14 bitsy) 15 bitsz) 16 bitsANSWER: Y -- 15 BITS99. When programming in C, ++A is symbolic for what operation?w) A = A + 1x) A = A + By) A = 1z) A = 0ANSWER: W -- A = A + 1100. When programming in C, for what values of "A" will if(W) evaluate tofalse?ANSWER: A = 0101. What type of memory is used to hold application programs whilethey are being executed and may be cleared when the computer is turned off?w) ROMx) EPROMy) RAMz) DISKANSWER: Y -- RAM

Page 22: Question 1

102.What command would you type to return to DOS from BASIC?w) exitx) quity) endz) systemANSWER: Z – SYSTEM103. In which language is this a valid statement: A + B++w) FORTRANx) COBOLy) BASICz) CANSWER: Z -- C104. Which of the following is NOT an operating system?w) XENIXx) SQLy) PC DOSz) CP/MANSWER: X -- SQL105. The process of loading an operating system is called:w) bootingx) formattingy) compilingz) debuggingANSWER: W -- BOOTING

Page 23: Question 1

106.The process of preparing a floppy diskette for use is called:w) assemblingx) translatingy) parsingz) formattingANSWER: Z – FORMATTING107. A program that converts a high-level language source file into amachine-language file is called a:w) translatorx) assemblery) compilerz) linkerANSWER: Y -- COMPILER108. The binary number 1011 is expressed in hexadecimal notation as:w) 11x) 13y) Az) BANSWER: Z -- B109. When using COBOL, a serial search of a table begins with the firstentry in the table, while a binary search of a table begins with what entry? Is it the:w) First x) middle y) last z) none of the aboveANSWER: X -- MIDDLE

Page 24: Question 1

110.What is the most common method used to erase EPROM chipsbefore re-programming them?w) magnetic fieldx) ultraviolet lighty) program all null values in memoryz) high-pitched soundANSWER: X -- ULTRAVIOLET LIGHT111. Rules that govern how computers communicate are called:w) system standardsx) topologyy) protocolsz) baud rateANSWER: Y -- PROTOCOLS112. Which database modeling technique is well known for its use ofhigh level data manipulation languages, such as SQL, QUEL and QBE?w) relational modelx) network modely) herarchical modelz) entity-relationship modelANSWER: W -- RELATIONAL MODEL

Page 25: Question 1

113.Programs written in the C programming language consist of one ormore functions. Which function is always the first to be executed?w) openx) exity) menuz) mainANSWER: Z – MAIN

114. EXE (read: E - X - E), COM (read: C - O - M) and BAT (read: B - A- T) files are all executable under MS-DOS. In which order will DOS look for these files?ANSWER: COM first; EXE second; BAT last

115. One K of COMPUTER MEMORY is equivalent to:w) 1,000 bytesx) 2 to the eighth power bytesy) 2 to the tenth power bytesz) 640 thousand bytesANSWER: Y -- 2 TO THE TENTH POWER BYTES

Page 26: Question 1

116.What DOS command gives you the total disk space, amount ofavailable disk space, and the amount of free memory?w) MEM (read: M - E - M)x) CHKDSK (read: C - H - K - D - S - K)y) SPACE (read: S - P - A - C - E)z) MEMORY (read: M - E - M - O - R - Y)ANSWER: X – CHKDSK

117. A logical variable contains what type of data?w) numericx) true/falsey) alphanumericz) memory addressANSWER: X -- TRUE/FALSE

118. Which of the following will NOT decrease the processing time of acomputer?w) increasing the processor speedx) increasing the size of the data busy) increasing the resolution of the monitorz) decreasing the access time of a hard diskANSWER: Y -- INCREASING THE RESOLUTION OF THE MONITOR

Page 27: Question 1

119.What does the acronym G-I-G-O mean?ANSWER: GARBAGE IN, GARBAGE OUT

120. What three letter word is commonly used to refer to an error in a computer program?ANSWER: BUG

121. What is the name of the marker that indicates where the next typed character will appear on the screen?ANSWER: CURSOR

122. You are laying out the logic of your computer program before you begin writing it. The graphical representation that you create is called aw) filex) simulationy) listingz) flowchartANSWER: Z -- FLOWCHART

Page 28: Question 1

123.Which of the following does NOT belong?w) printerx) plottery) monitorz) keyboardANSWER: Z -- KEYBOARD (Keyboard is input, others are output devices)

124. Computers are playing a major role in today's communicationrevolution. What is the technological field involved in the control and intercommunication of information handling machines, the nervous systems of animals and man in order to improve communication?ANSWER: CYBERNETICS

125. What reserved word in Pascal is used to define constants?ANSWER: CONST

126. Which of the following is NOT characteristic of the secondgeneration of operating systems of the early 1960's:w) real time computingx) multiprogrammingy) multiprocessingz) networkingANSWER: Z -- NETWORKING

Page 29: Question 1

127.What does the acronym C-A-M refer to?ANSWER: COMPUTER AIDED (OR ASSISTEZ) MANUFACTURING

128. At what company or research organization was the first transistordeveloped?ANSWER: BELL LABORATORIES

129. Which of the following is NOT characteristic of the first generationof computers?w) vacuum tubesx) integrated circuitsy) magnetic drumsz) punched cardsANSWER: X -- INTEGRATED CIRCUITS

130. Which of the following is NOT one of the internal components of aCPU?w) control - sequencerx) M-D-Ry) M-A-Rz) floppy diskANSWER: Z -- FLOPPY DISK

Page 30: Question 1

131.The smallest unit of information isw) a byte (Pronounced: bite)x) a bity) a nibblez) a blockANSWER: X -- A BIT

132. Which computer pioneer was also a Rear Admiral of the U.S.Navy?w) Steve Jobsx) John Backusy) John von Neumannz) Grace HopperANSWER: Z -- GRACE HOPPER

133. The ability of a computer to learn from experience by storinginformation and applying it to new situations is referred to asw) artificial intelligencex) automated data processingy) asynchronous transmissionz) encryptionANSWER: W -- ARTIFICIAL INTELLIGENCE

Page 31: Question 1

134.When you boot a computer you arew) submitting a batch jobx) debugging a programy) loading the operating systemz) kicking it in frustrationANSWER: Y -- LOADING THE OPERATING SYSTEM

135. Where do you find a write protect notch?w) on a computer chipx) on a punched cardy) in a read only memoryz) on a floppy diskANSWER: Z -- ON A FLOPPY DISK

136. Some programs allow the computer's video display to be dividedinto separate areas in order to look at more than one item or portions of an item simultaneously.These are called?w) disksx) windowsy) fontsz) directoriesANSWER: X -- WINDOWS

Page 32: Question 1

137.A prescribed set of well-defined instructions for solvingmathematical problems is calledw) a compilerx) a codey) a descriptionz) an algorithmANSWER: Z – ALGORITHM

138. In order to write on a floppy disk with your IBM PC, (PronouncedI B M P Y) you must firstw) digitize itx) format ity) compile itz) hardware itANSWER: X -- FORMAT IT

139. An electrical pathway within a computer is called:w) bufferx) sectory) busz) trackANSWER: Y -- BUS

Page 33: Question 1

140.The letters UPC stand for:w) United Parcel Corporationx) Universal Product Codey) Universal Price Codez) Universal Personal ComputerANSWER: X -- UNIVERSAL PRODUCT CODE

141. In computer science what does the acronym JCL stand for?w) Justified Computer Languagex) Justified Complete Languagey) Job Computerized Languagez) Job Control LanguageANSWER: Z -- JOB CONTROL LANGUAGE

142. A Field is a related group ofw) Recordsx) Filesy) Charactersz) CablesANSWER: Y -- CHARACTERS

Page 34: Question 1

143.In DOS, what command allows a ASCII file to be viewed?w) TYPEx) SHOWy) DISPLAYz) VIEWANSWER: W – TYPE

144. The type of data storage that is considered to be non-volatile is?w) R-O-Mx) R-A-My) TAPEz) DISK

ANSWER: W -- R-O-M

145. The first general-purpose commercially available computer systemwas called?w) HALx) UNIVAC Iy) ENIACz) MARK IANSWER: X -- UNIVAC I

Page 35: Question 1

146.Electronic wire connector cables can be of two types, Serial and ?w) Duplexedx) Parallely) Linkingz) ExpandedANSWER: X – PARALLEL

147. One of the things that separates a "Terminal" from a "PC" is that the terminal does not have a what?w) Keyboardx) Monitory) Power cordz) CPUANSWER: Z – CPU148. The "First Generation" of computers used?w) Gearsx) Vacuum Tubesy) Transistorsz) No Electricity, MechanicalANSWER: X -- VACUUM TUBES

Page 36: Question 1

149.In communications an extra bit is added to each byte to aid inchecking data for accuracy. This bit is known as what?ANSWER: PARITY

150. What does the acronym GIGO mean?ANSWER: GARBAGE IN, GARBAGE OUT

151. Substances in the read heads of computer disk drives use a property known as magnetoresistance to access a floppy disk. A new class of magnetoresistant substanceshas been made fromw) uranium and leadx) aluminum and irony) copper and bariumz) silver and cobaltANSWER: Z -- SILVER AND COBALT152. OS/2 isw) single-user, single taskingx) multi-user, single taskingy) multi-user, multitaskingz) single-user, multitaskingANSWER: Z -- SINGLE-USER, MULTITASKING

Page 37: Question 1

153.How many color dots make up one color pixel on a screen?w) 256x) 16y) 3z) 1ANSWER: Y – 3

154. Which inherent intrinsic property is common to both C++ and C?w) polymorphismx) inheritancey) classesz) structuresANSWER: Z -- STRUCTURES

155. The term used to indicate, in bits per second, the transmission speed of a modem is?ANSWER: BAUD

156. An eight bit byte is capable of representing how many differentcharacters?w) 64 x) 128 y) 256z) 512ANSWER: Y -- 256

Page 38: Question 1

157.The language that is the lowest level is:w) assemblyx) high-levely) machinez) application generatorANSWER: Y – MACHINE158. Choice: The person credited with designing the Harvard Mark I Computer is:w) Aikenx) Atanasoffy) Eckertz) MauchlyANSWER: W -- AIKEN

159. Which type of network is best suited for businesses which mustcarefully control and coordinate the operations of distributed branch outlets?w) hierarchicalx) local areay) ringz) starANSWER: Z -- STAR

Page 39: Question 1

160.The language that has become the most widely used microcomputerhigh level language is:w) PASCALx) COBOLy) BASICz) Small talkANSWER: Y – BASIC161. Modular programming relates to the use of which of the following:w) Data filesx) Subroutinesy) Conditional IF statementsz) Do loopsANSWER: X -- SUBROUTINES

162. What computer programming language was developed in the 1970'sfor the purpose of creating the UNIX operating system?w) FORTRANx) COBOLy) ADAz) CANSWER: Z -- "C"

Page 40: Question 1

163.How many characters are there in the official standard ASCIIcharacter set? (pronounced ask-ee)ANSWER: 128

164. Who invented the computer architecture that put program memory and data memory in the same memory unit?ANSWER: VON NEUMANN (Pronounced noy-man)

165. A virtual memory system (VMS) means:w) data are copied from slower R-O-M to faster R-A-Mx) the hard drive is accessed as if it were R-A-My) R-A-M is accessed as if it were a hard drivez) there is no upper limit on the amount of R-A-M addressedANSWER: X -- THE HARD DRIVE IS ACCESSED AS IF IT WERE R-A-M

166. In a microcomputer, what benefit does a coprocessor provide?w) Supports both color and monochrome monitorsx) Allows multi-user operationsy) Increases the speed of floating point mathematical computationsz) Handles network communication protocolsANSWER: Y -- INCREASES THE SPEED OF FLOATING POINTMATHEMATICAL COMPUTATIONS

Page 41: Question 1

167.Which of these is a standard interface for serial data transmission?w) ASCIIx) RS232Cy) LU6.2z) CentronicsANSWER: X -- RS232C168. What is the process that uses hardware and software to "imitate" a computer system in order to run programs that would otherwise be incompatible?w) Mappingx) Cloningy) Migrationz) EmulationANSWER: Z -- EMULATION

169. What is the term for a temporary storage area that compensates fordifferences in data rate and data flow between devices?w) Bufferx) Busy) Channelz) ModemANSWER: W -- BUFFER

Page 42: Question 1

170.Consider the following algorithm: x is initialized to 2; x is thenreplaced by its double four times in sequence; x is then decremented by 2 three times in sequence.What is the final value of x.ANSWER: 26.

171. Which of the following types of computer software is least likely to translate the commands of a computer program written in a language like BASIC into executablecomputer machine instructions?w) interpreterx) word processory) compilerz) debuggerANSWER: X -- WORD PROCESSOR

172. Numbers ranging from -16,000 to +16,000 might be stored in acomputer readable file as 16-bit integers, or in an ASCII (pronounced ask-ee) representation, which could be viewed with a text-editor or word processor. For a large file, how many times bigger would the ASCII file be than the binary version?w) no bigger x) twice as big y) four times as bigz) eight times as bigANSWER: Y -- FOUR TIMES AS BIG

Page 43: Question 1

173.What is the decimal equivalent of the binary number 10111?w) 21x) 23y) 39z) 42ANSWER: X – 23

174. What term is used to describe a function that calls itself?w) Iterativex) Assimilativey) Recursivez) CooperativeANSWER: Y -- RECURSIVE175. What is the name of the computer technology that is expected to provide the most powerful supercomputers within the next 10 years?w) Fiber opticsx) Laser dopingy) Parallel computingz) Very large integrated circuitsANSWER: Y -- PARALLEL COMPUTING

Page 44: Question 1

176.A record is related to a file, as a statement is related to aw) procedurex) filey) programz) dataANSWER: Y – PROGRAM

177. The life-cycle of most large software development projects, such as those for NASA and DOD, goes through several well-defined phases sometimes referred to as the water-fall method. A simple version of the water-fall method consists of 4 phases. Which of the following would be the second phase?w) software designx) codingy) requirements analysisz) testingANSWER: W -- SOFTWARE DESIGN178. In the late 1970's, Pascal inventor Niklaus Wirth designed thelanguage specifically for:w) high speed computersx) teaching programming to studentsy) helping market IBM personal computersz) use on any type of operating systemANSWER: X -- TEACHING PROGRAMMING TO STUDENTS

Page 45: Question 1

179.On IBM-PC based microcomputer systems, the 'boot section'stores:w) information on file sizesx) a copy of the operating systemy) code needed to load the operating systemz) all of the aboveANSWER: Y -- CODE NEEDED TO LOAD THE OPERATING SYSTEM

180. The terms FIFO and LIFO would most likely arise during adiscussion of:w) storage mediax) binary treesy) compiler designz) queuesANSWER: Z -- QUEUES

181.

Page 46: Question 1

181.Which of the following is a computer program that appears to be legitimate but performs an illicit activitywhen it is run?a. Redundant verification.b. Parallel count.c. Web crawler.d. Trojan horse.ANSWER:Choice "d" is correct. A Trojan horse (like the wooden horse in Helen of Troy) is a program that appears to have a useful function but that contains a hidden and unintended function that presents a security risk (appears to be legitimate but performs an illicit activity when it is run).Choice "a" is incorrect. It is unclear what redundant verification is. One possibility if that it means verifying something twice to make sure that it is done once. This term is probably just made up.Choice "b" is incorrect. A parallel count appears to be the counting of bits in a parallel fashion. It appearsto have something to do with digital circuits in digital clocks, watches, microwave ovens, VCRs, and the like. It is not a computer program.Choice "c" is incorrect. A web crawler (also known as a web spider or web robot) is a program which browses the web in a methodical, automated manner. Web crawlers are mainly used to create a copy of visited web pages for later processing by a search engine. Web crawlers can also be used for automating maintenance tasks on a web site. Web crawlers can also be used to gather specific types of information from web pages. There is nothing illicit about a web crawler.

Page 47: Question 1

182. Consider the following functions.void Myst(int a, int & b){a *= b;b = 2 + a;}void Test(){int u = 2;int v = 3;Myst(u, v);cout << u << " " << v << endl;}

What is printed as a result of the call Test() ?(A) 2 3(B) 2 8(C) 6 3(D) 6 8(E) 8 3

Page 48: Question 1

183. Assume that the following definitions have been made.int num = 10;int sum;Which of the following code segments correctly computes the sumof the first 10 multiples of 5 (i.e., 5, 10, . . ., 50)?(A) sum = 5;while (num > 1){sum += sum;num--;}(B) sum = 5;while (num > 0){sum += sum;num--;}(C) sum = 0;while (num > 0){num--;sum += 5 * num;}(D) sum = 0;while (num >= 0){num--;sum += 5 * num;}(E) sum = 0;while (num > 0){sum += 5 * num;num--;}

Page 49: Question 1

184. Consider the following functions.int F1(int len) int F2(int len){ {int tot = 0; int tot = 0;int k = 0; int k;while (k < len) for (k = 0; k < len; k++){ {tot += k; tot += k;k++; }}return tot; return tot;} }For which values of len do F1(len) and F2(len) return thesame result?I. Any value less than zeroII. The value zeroIII. Any value greater than zero(A) I only(B) II only(C) III only(D) I and II only(E) I, II, and III

Page 50: Question 1

185. Consider the following function.void Mystery(int n){if (n >= 2){Mystery(n / 3);}cout << n << " ";}Which of the following is output as a result of the call Mystery(27) ?(A) 0 27(B) 1 3 9 27(C) 3 9 27(D) 27 0(E) 27 9 3

Page 51: Question 1

186. The expression !((x > y) && (y <= 3)) is equivalent to whichof the following?(A) (x > y) && (y <= 3)(B) (x > y) || (y <= 3)(C) (x < y) || (y >= 3)(D) (x <= y) || (y > 3)(E) (x <= y) && (y > 3)

187. Consider the following code segment.apmatrix<int> M(10, 10, 1);int k;for (k = 0; k < 10; k++){M[k][k] = 0;}Which of the following best describes what happens when the loop is executed?(A) All entries of matrix M are set to zero.(B) One entry of matrix M is set to zero.(C) One column of matrix M is set to zero.(D) One row of matrix M is set to zero.(E) One diagonal of matrix M is set to zero.

Page 52: Question 1

188. Consider the following functions.apstring Laugh(const apstring & word, int num){int k;apstring result = "";for (k = 0; k < num; k++){result += word;result += " ";}return result;}void Test(){apstring str("ha");cout << Laugh(Laugh(str, 2), 3) << endl;}Which of the following is output as a result of the call Test() ?(A) ha(B) ha ha(C) ha ha ha(D) ha ha ha ha ha ha(E) Nothing will be output because a runtime error will occur.

Page 53: Question 1
Page 54: Question 1
Page 55: Question 1
Page 56: Question 1
Page 57: Question 1
Page 58: Question 1
Page 59: Question 1
Page 60: Question 1
Page 61: Question 1

1. Give two reasons why it important for the design team to keep a meticulous record of the design decisions that are made?Soln. Question 1:The reasons for meticulous recording of the design decisions are:a) It is possible that while the product is being designed, a dead end would be reached. Thus the design team would then have to backtrack and redesign certain sections. Written records of why specific decisions were made will serve as to assist the team in this process.b) By having this documentation handy it will facilitate easier post delivery maintenance (i.e. enhancements).

Page 62: Question 1
Page 63: Question 1

2. You are given the responsibility to market your employer’s software developmentfirm to potential customers. You are rewarded with a 5% commission on the sale foreach customer gained. Your first appointment is with Mrs. Gratitude who requiressoftware to help manage her business. However, she is leaning towards taking herproblem to a rival company, as she is very concerned about the time taken to developthe product. To arrest her fears you promise her that you would use the latest CASEtools to help manage all aspects of the development process, including analysismodelling and maintaining data dictionaries.A starry-eyed Mrs. Gratitude, now bemused by the jargon, asks you to explain thefollowing:i) What does a case of tools (CASE tools) have to do with software engineering?ii) What is analysis modelling?iii) Define data dictionary giving an example of what one may contain?iv) How could the use of these tools minimise the duration of the softwaredevelopment process?

Soln. Question 2:Essential components to the answers are listed below:(i) .• First indicate that it is not a case of tools but CASE tools.• Special software termed “Computer Aided Software Engineering” (CASE) can beused to assist the introduction of software engineering techniques.(ii) Analysis modelling refers to the technical representation of a system using one ormore of the following diagrammatic and textual techniques: entity relationshipdiagrams, data flow diagrams, data dictionaries, and state transitions diagrams.(iii) Data Dictionary - ``An organized listing of all data elements that are pertinent to thesystem, with precise, definitions so that both user and system analyst will have acommon understanding of inputs, outputs, components of stores and [even]intermediate calculations.”

Page 64: Question 1
Page 65: Question 1

3. Give two advantages and two disadvantages of the following specificationtechniques:i) Questionnairesii) Client Documentsiii) Observations

soln. Question 3:Two advantages of questionnaires are:a) Overcomes the burden of multiple interviewsb) Can be filled out by large numbers of peopleTwo disadvantages of questionnaires are:a) Lacks interactivityb) Must be carefully designedTwo advantages of client documents are:a) Detailed information regarding the operating of the client organisation can becaptured and the types of data used by the organisation can be tracedb) Less invasive/disruptive than interviews.Two disadvantages of client documents are:a) May have legal issues is the document contain sensitive information.b) Documents may not necessarily outline how the process is actually carried out.They may be inaccurate or out of date.

Page 66: Question 1

Two advantages of observations are:a) Use of video cameras can capture what happens in the office, making thistechnique less intrusive.b) One can directly observe what actually happens wrt a given process as oppose tohow it is documented.Two disadvantages of observations are:a) May have privacy issuesb) May have legal issues

4. List and describe three (3) important user design principles

Page 67: Question 1

Soln. Question 4:. . . . . . . . .1. process should not suffer from tunnel vision2. should be traceable to the analysis model3. should not reinvent the wheel4. should minimize intellectual distance between the software and the

problem as it exists in5. the real world6. should exhibit uniformity and integration7. should be structured to accommodate change8. should be structured to degrade gently, even with bad data, events, or

operating9. conditions are encountered10.should be assessed for quality as it is being created11.should be reviewed to minimize conceptual (semantic) errors12.Any three could be used and their descriptions are given online.

Page 68: Question 1

5. Elegant Software Solutions has been employing the Build-And-Fix approach tosoftware development for the past 3 years. This has resulted several lawsuits for latedelivery and poor quality software. To address this issue senior management hashired you as a quality assessment consultant to:a. Explain the source of the problem andb. document an alternative software development strategies. The proposed strategy must be fully explained, giving any inherent advantages and disadvantages.

Solution Question 5The source of the problem lies in the fact that ESS is using the Build-And-Fix approach. This approach should never be used to produce software as its adhoc development approach has no clearly defined phases. Moreover with the lack of project management (incl. Risk management) and quality assessment monitoring this approach is doomed to fail. In essence, the product is built and modified as many times as possible until itsatisfies the client. The cost of using this approach is greater than if specifications are drawn up and a design is carefully developed.

Page 69: Question 1
Page 70: Question 1
Page 71: Question 1
Page 72: Question 1
Page 73: Question 1
Page 74: Question 1
Page 75: Question 1

1. Which of the foll is not a protocol.HTTP PIM PSIAns:  PSI (check)2 Which of the following does not help with security?Good PasswordUpdate AntivirusVLANAns:  VLAN3> What was the prob with Intel ProcessorCacheFPUNONEAns:  FIND OUT AND LET ME KNOW4 What does MIME stand forAns: Multipurpose Mail Exchange Protocol5 What does XP stand for in WIN-XpAns:  Experience6 Who is associated with CAns:  Dennis Ritchie

Page 76: Question 1

7 Which of the foll is not a IM clientAOLMSNJABBERXINGCAns:  XINGC8 What does ERP stand for?Ans:  Enterprise resource planning.9 Who is associated with HOTMAILSABEER Bhatia and Jack SmithSABEER Bhatia and Bill GatesAns: SABEER Bhatia and Jack Smith10 What does UNIX stand 4?UNiplexed Information Computing System. UNICS later known as UNIX.

Page 77: Question 1

11 Which of the following is not an app server?BLUESTONEWEBSPHERETOMCATJBOSSAnswer:  BLUESTONE is not an app server.HP GENERAL CSE (Computer science and engineering branch B.tech BE) questions:12 What do u call software embedded in ROMBIOSFIRMWARESHAREWAREFREEWAREAns:  BIOS (Verify and plz let me know)13 What is semaphore used 4????14 Integral Constraint helps in???Ans:  Solving Inconsistent Data prob.15 PING usesAns:  ICMP16 IP ADDRESS occupies4 bytes8 bytes16 bytes6 bytesAns:  I wrote 8. correct ans 4

Page 78: Question 1

17 Which Data Structure helps SearchingSTACKLINKED LISTHASHAns:  HASH18 Q on Binary tree Depth?2^n2^n – 1log n

19 Database should haveAns:  ACID properties.20 VPN stands 4Ans:  virtual private n/w21 what does fork() return 2 parentchild pid0Ans:  022> What do u call the relationship b/e a table and its columnsAns:  SchemaHP 12 Questions on c & c++

Page 79: Question 1

23 What is true about c++Ans:  It can have virtual constructors24 result of i=6; printf(”%d”,i++*i++)3654cant sayAns:  Can’t say (compiler dependent)25 output ofchar str[20] = “PANKAJ”printf(”%d%d”,sizeof(str),strlen(str))Answer 20,6

26 Which of the following cant be used across files?externvolatilestaticconstAns:  static. (i wrote volatile)27 union u{ int i; char c;};sizeof(u);Ans:  428 Identify the error below:5[[a]5["abc"]Ans:  5["abc"]

Page 80: Question 1

26 Which of the following cant be used across files?externvolatilestaticconstAns:  static. (i wrote volatile)27 union u{ int i; char c;};sizeof(u);Ans:  428 Identify the error below:5[[a]5["abc"]Ans:  5["abc"]

Page 81: Question 1

8.1.1 An entity is(a) a collection of items in an application(b) a distinct real world item in an application(c) an inanimate object in an application(d) a data structure

8.1.2 Pick entities from the following:(i) vendor(ii) student(iii) attends(iv) km/hour(a) i, ii, iii (b) i, ii, iv(c) i and ii (d) iii and iv8.1.3 A relationship is(a) an item in an application(b) a meaningful dependency between entities(c) a collection of related entities(d) related data8.1.4 Pick the relationship from the following:(a) a classroom(b) teacher(c) attends(d) cost per dozen

Page 82: Question 1

8.1.5 Pick the meaningful relationship between entities(a) vendor supplies goods(b) vendor talks with customers(c) vendor complains to vendor(d) vendor asks prices8.1.6 The entity set is a(a) set of entities(b) collection of different entities(c) collection of related entities(d) collection of similar entities8.1.7 Pick entity set from the following(a) all vendors supplying to an organization(b) vendors and organizations they supply(c) vendors and transporters(d) a vendor supplying to many organizations

Page 83: Question 1

8.1.8 Attributes are(i) properties of relationship(ii) attributed to entities(iii) properties of members of an entity set(a) i (b) i and ii(c) i and iii (d) iii8.1.9 The attributes of relationship teaches in teacher teaches course should be(a) teacher code, teacher name, dept, phone no(b) course no, course name, semester offered, credits(c) teacher code, course no, semester no(d) teacher code, course no, teacher name, dept, phone no8.1.10 The expansion of E-R diagram is(a) Entity-Relationship diagram(b) Entity-Relative diagram(c) Entity-Relation diagram(d) Entity-Rationalized diagram8.1.11 In an E-R diagram entities are represented by(a) circles(b) rectangles(c) diamond shaped box(d) ellipse

Page 84: Question 1

8.1.12 In an E-R diagram relationship is represented by(a) circles(b) rectangles(c) diamond shaped box(d) ellipse8.1.13 Entities are identified from the word statement of a problem by(a) picking words which are adjectives(b) picking words which are nouns(c) picking words which are verbs(d) picking words which are pronouns8.1.14 Relationships are identified from the word statement of a problem by(a) picking words which are adjectives(b) picking words which are nouns(c) picking words which are verbs(d) picking words which are pronouns8.1.15 One entity may be(a) related to only one other entity(b) related to itself(c) related to only two other entities(d) related to many other entities

Page 85: Question 1

8.1.1 b 8.1.2 c 8.1.3 b 8.1.4 c 8.1.5 a 8.1.6 d8.1.7 a 8.1.8 c 8.1.9 c 8.1.10 a 8.1.11 b 8.1.12 c8.1.13 b 8.1.14 c 8.1.15 d

Page 86: Question 1

8.2.1 By relation cardinality we mean(a) number of items in a relationship(b) number of relationships in which an entity can appear(c) number of items in an entity(d) number of entity sets which may be related to a given entity8.2.2 If an entity appears in only one relationship then it is(a) a 1:1 relationship(b) a 1:N relationship(c) a N:1 relationship(d) a N:M relationship8.2.3 If an entity appears in N relationships then it is(a) a 1:1 relationship(b) a 1:N relationship(c) a N:1 relationship(d) a N:M relationship

Page 87: Question 1

8.2.4 If an entity appears in not more than 5 relationships then it is a(a) 1:1 relationship(b) 1:5 relationship(c) 5:1 relationship(d) 5:5 relationship8.2.5 A pilot can fly three types of planes and a plane can be piloted by any qualifiedpilot. The pilot-plane type relationship is(a) N:3(b) 3:N(c) 1:3(d) 3:18.2.6 A student can take not more than 5 subjects in a semester. The number ofstudents allowed in a subject in a semester is not more than 40. The student– subject relationship is:(a) 5:40(b) 40:5(c) N:5(d) 40:M

Page 88: Question 1

8.2.7 The following E-R diagram is interpreted as follows:(a) A doctor treats upto N patients(b) A doctor treats exactly N patients(c) A doctor may treat upto N patients; Some doctors may not treat any patients(d) A doctor will treat patients based on some conditions

Page 89: Question 1

8.2.8 A relation is(a) an entity(b) a relationship(c) members of a relationship set(d) members of an entity set or a relationship set8.2.9 Rows of a relation are called(a) tuples(b) a relation row(c) a data structure(d) an entity8.2.10 The rows of a relation(a) must be in specified order(b) may be in any order(c) in ascending order of key(d) in descending order of key8.2.11 The columns of a relation(a) must be in specified order(b) may be in any order(c) with key field in first column(d) with largest width column last

Page 90: Question 1

8.2.12 Relations are used in logical database design because(i) sound theory of relations facilitates systematic design of relationaldatabases(ii) they are very popular(iii) they are flat files and easy to store and retrieve from computer’smemory(iv) E-R diagrams allow design of relations(a) i and ii (b) i and iii(c) ii and iii (d) iii and iv

8.2.1 b 8.2.2 a 8.2.3 b

8.2.4 b 8.2.5 a 8.2.6 b

8.2.7 c 8.2.8 d 8.2.9 a

8.2.10 b 8.2.11 b 8.2.12 b

Page 91: Question 1

8.3.1 Normalization is a process of restructuring a relation to(a) minimize duplication of data in a database(b) maximize duplication of data to ensure reliability(c) make it of uniform size(d) allow addition of data

8.3.2 Normalization of database is essential to(i) avoid accidental deletion of required data when some data is deleted(ii) eliminate inconsistencies when a data item is modified in the database(iii) allows storage of data in a computer’s disk(iv) use a database management system(a) i and iii (b) i and ii(c) ii and iii (d) ii and iv8.3.3 The process of normalization(a) is automatic using a computer program(b) requires one to understand dependency between attributes(c) is manual and requires semantic information(d) is finding the key of a relation

Page 92: Question 1

8.3.4 The following relation is not normalized because

(a) It is difficult to store due to non–uniform size of the attributes(b) Roll no. 4568 have 3 course line whereas Roll no. 4954 has only one courseline(c) The composite attribute (CS 101, C.S., 1) is repeated(d) Some item lines have composite attributes8.3.5 The relation given in Exercise 10.4.4 may be converted to 1 NF relation by(a) eliminating composite attributes(b) eliminating common attributes(c) duplicating common attributes as many times as lines in correspondingattributes(d) putting composite attributes in a separate table

Page 93: Question 1

8.3.6 A relation is said to be in 1NF if(a) there is no duplication of data(b) there are no composite attributes in the relation(c) there are only a few composite attributes(d) all attributes are of uniform type8.3.7 The number of normal forms which has been proposed and discussed in the book are(a) 3 (b) 4(c) 5 (d) 68.3.8 A relation which is in a higher normal form(a) implies that it also qualifies to be in lower normal form(b) does not necessarily satisfy the conditions of lower normal form(c) is included in the lower normal form(d) is independent of lower normal forms8.3.9 Given an attribute x, another attribute y is dependent on it, if for a given x(a) there are many y values(b) there is only one value of y(c) there is one or more y values(d) there is none or one y value

Page 94: Question 1

8.3.10 An attribute y may be functionally dependent on(i) a composite attribute x,y(ii) a single attribute x(iii) no attribute(a) i and ii (b) i and iii(c) ii and iii (d) iii8.3.11 A second Normal Form (2 NF) relation should(a) be in 1 NF(b) not have a composite key(c) not have attributes dependent on key attribute(d) not have attributes dependent on one another8.3.12 A relation is said to be in 2 NF if(i) it is in 1 NF(ii) non-key attributes dependent on key attribute(iii) non-key attributes are independent of one another(iv) if it has a composite key, no non-key attribute should be dependent onpart of the composite key(a) i, ii, iii (b) i and ii(c) i, ii, iv (d) i, iv

Page 95: Question 1

8.3.13 Given the following relationvendor order (vendor no, order no, vendor name, qty supplied, price/unit) it is notin 2 NF because(a) it is not in 1 NF(b) it has a composite key(c) non-key attribute vendor name is dependent on vendor no. which is one partof the composite key(d) Qty supplied and price/unit are dependent8.3.14 Given the following relationvendor order (vendor no, order no, vendor name, qty supplied , price/unit)the second normal form relations are(a) vendor (vendor no, vendor name) qty (qty supplied, price/unit)order (order no, qty supplied)(b) vendor (vendor no, vendor name) order (order no, qty supplied, price/unit)(c) vendor (vendor no, vendor name) order (order no, qty supplied, price/unit)vendor order (vendor no, order no) (d) vendor (vendor no, vendor name, qty supplied, price/unit) vendor order (order no, vendor no)8.3.15 A third Normal Form (3 NF) relation should(a) be in 2 NF(b) not have complete key(c) not be 1 NF(d) should not have non-key attributes depend on key attribute

Page 96: Question 1

8.3.16 A relation is said to be in 3 NF if(i) it is in 2 NF(ii) non-key attributes are independent of one another(iii) key attribute is not dependent on part of a composite key(iv) has no multi-valued dependency(a) i and iii (b) i and iv(c) i and ii (d) ii and iv

8.3.17 Given the following relation it is not 3 NF becauseStudent (roll no, name, course no, course max. marks, year of study,address)(a) it is not in 2 NF(b) it does not have composite key(c) non-key attributes course no and course max. marks are functionallydependent(d) it has more than 3 non-key attributes

Page 97: Question 1

8.3.18 Given the following relationStudent (roll no, name, course no, course max. marks, year of study,address)The corresponding 3 NF relations are(a) student (roll no, name, year of study, address) course (course no, course max. marks)(b) student ( roll no, name, year of study, address) student (roll no, course no)course (course no, course max. marks)(c) student (roll no , name, address) year (roll no, year of study)course (course no, course max. marks)(d) student (roll no, name, address) course (course no, course max. marks, year of study)8.3.19 Boye Codd Normal Form (BCNF) is needed when(a) two non-key attributes are dependent(b) there is more then one possible composite key(c) there are two or more possible composite overlapping keys and one attributeof a composite key is dependent on an attribute of another composite key(d) there are two possible keys and they are dependent on one another8.3.20 A relation is said to be in BCNF when(a) it has overlapping composite keys(b) it has no composite keys(c) it has no multivalued dependencies(d) it has no overlapping composite keys which have related attributes

Page 98: Question 1

8.3.21 A 3 NF relation is converted to BCNF by(a) removing composite keys(b) removing multivalued dependencies(c) dependent attributes of overlapping composite keys are put in a separaterelation(d) dependent non-key attributes are put in a separate table8.3.22 BCNF is needed because(a) otherwise tuples may be duplicated(b) when a data is deleted tuples may be lost(c) updating is otherwise difficult(d) when there is dependent attributes in two possible composite keys one of theattributes is unnecessarily duplicated in the tuples

8.3.23 Given the relationSupplier(s_id, p_order, s_name, qty)Given that there is a unique s_name for each s_id and that s_id, p_order is acomposite key, find the correct statement among the following:(i) this relation is a BCNF(ii) this is 3 NF relation(iii) this is a 2 NF relation(iv) this is a 1 NF relation(a) i and ii (b) ii and iii(c) i and iv (d) i and iii

Page 99: Question 1

8.3.24 Given the relation of Exercise 10.7.5 it is reduced to the following BCNFrelation(a) Supplier (s_ids, s_name)Purchase (s_id, p_order, qty)(b) Supplier (s_id, s_name)Purchase (p_order, qty)(c) Purchase (s_id, p_order)Supplier (s_name, qty)(d) Supplier (s_id, s_name, qty)Purchase (s_id, p_order)8.3.25 Fourth normal form (4 NF) relations are needed when(a) there are multivalued dependencies between attributes in composite key(b) there are more than one composite key(c) there are two or more overlapping composite keys(d) there are multivalued dependency between non-key attributes8.3.26 A 3 NF relation is split into 4 NF(a) by removing overlapping composite keys(b) by splitting into relations which do not have more than one independentmultivalued dependency(c) removing multivalued dependency(d) by putting dependent non-key attribute in a separate table

Page 100: Question 1

8.3.27 A relation project guidanceProject Guidance(professor, project, student no. st-name, dept) A professor can give many projects to many students A project will have many students A project may be guided by many professorsThe 4 NF relation corresponding to this are

(a) Prof_Project (professor, st_name, dept) Proj_stud (project, student no.)(b) Prof_stud (professor, student no) Proj_stud (project, student no)Student (student no, st_name, dept) (c) Student (student no, st_name, dept) Professor(professor, project)(d) Professor( professor, project, dept) Student (student no, st_name, dept)

8.3.28 The project guidance relation of Exercise 10.8.3 needs further normalizationto 5 NF because(a) There are too many multivalued dependencies(b) Multivalued dependency and simple dependency are mixed in the 4 NFrelation(c) Spurious tuples got introduced when the 4 NF relations are combined due to the fact that a professor can guide only specified projects(d) 4 NF relations have composite keys

Page 101: Question 1

8.3.29 5 NF relations equivalent to the relation of Exercise 10.8.3 are(a) Prof_stud (professor, student_no) Proj_stud ( project, student_no)Prof_proj (professor, project) Student (student_no, st_name, dept)(b) Professor (professor, professor details) Student (student_no, st_name, dept)Project (project no, project details) (c) Prof_stud (professor, student_no ) Prof_proj (professor, project)(d) Prof_stud (professor, student_no) Stud_proj (student_no, project)Student (student_no, st_name, dept)

8.3.1 a 8.3.2 b 8.3.3 b 8.3.4 d

8.3.5 c 8.3.6 b 8.3.7 d 8.3.8 a

8.3.9 b 8.3.10 a 8.3.11 a 8.3.12 c

8.3.13 c 8.3.14 c 8.3.15 a 8.3.16 c

8.3.17 c 8.3.18 b 8.3.19 c 8.3.20 d

8.3.21 c 8.3.22 d 8.3.23 d 8.3.24 a

8.3.25 a 8.3.26 b 8.3.27 b 8.3.28 c 8.3.29 a

Page 102: Question 1

8.4.1 The ORDER PLACED FOR relation in Mini-case example 1 has the composite key order no, item code because(a) item code has a multivalued dependency with order no.(b) the non-key attributes are dependent on the composite key order no, itemcode(c) if order no is the only key we cannot find qty. ordered, price/unit, deliverytime(d) if item code is the only key we cannot find order no. uniquely

8.4.2 The relation SUPPLIES in Mini-case example 1 of Section 10.10 requiresnormalization because(a) it has a composite key with three attributes(b) the non-key attributes are dependent on part of composite key(c) the attributes item code and order no of the composite key have multivalueddependency(d) vendor code and order no have a multivalued dependency

Page 103: Question 1

8.4.3 TEACHES-COURSES relation in Mini-case example 2 is in(a) 3 NF. Does not need any further normalization (b) BCNF(c) 4 NF (d) unnormalized form8.4.4 TEACHER-STUDENT relation in Mini-case example 2 is required because(a) it is in 3 NF(b) it has a multivalued key(c) it has a composite key with multivalued dependency relation(d) Without this relation database is incomplete and some queries cannot beanswered

8.4.1 a 8.4.2 c 8.4.3 a 8.4.4 d

Page 104: Question 1

8.5.1 By redundancy in a file based system we mean that(a) unnecessary data is stored(b) same data is duplicated in many files(c) data is unavailable(d) files have redundant data8.5.2 Data integrity in a file based system may be lost because(a) the same variable may have different values in different files(b) files are duplicated(c) unnecessary data is stored in files(d) redundant data is stored in files8.5.3 Data availability is often difficult in file based system(a) as files are duplicated(b) as unnecessary data are stored in files(c) as one has to search different files and these files may be in different updatestates(d) redundant data are stored in files

Page 105: Question 1

8.5.4 Management policy changes are difficult to implement in a file based systembecause(a) relating data in different files is difficult(b) files are duplicated(c) redundant data are stored(d) unnecessary data is stored8.5.5 Some of the objectives of a database management system are to(i) minimize duplication of data(ii) ensure centralized management control of data(iii) ease retrieval of data(iv) maintain a data dictionary(a) i and ii (b) i, ii and iv(c) i and iii (d) i, ii and iii

8.5.6 A database is a(a) collection of files(b) collection of inputs and outputs of application(c) collection of related data necessary to manage an organization(d) data resource of an organization8.5.7 A database models data so that it is(a) appropriate for application(b) independent of application program(c) optimized for most frequent applications(d) optimized for all applications

Page 106: Question 1

8.5.8 A database should be designed to allow providing(a) different views of portions of data requested by an application(b) data only to selected applications as decided by an organization(c) a uniform view of data to all applications(d) data to all applications8.5.9 The abbreviation DBMS stands for(a) Data Base Manipulation System(b) Data Bank Manipulating System(c) Data Base Management System(d) Data Bank Management System8.5.10 A DBMS is(a) another name for database system(b) independent of a database(c) dependent on application programs(d) is a set of procedures which manage a database

8.5.11 A DBMS(a) is a set of procedures(b) manages a database(c) is a set of procedures to manage a database to provide data as required by applications(d) provides data to applications

Page 107: Question 1

8.5.12 One of the main objectives of a DBMS is to(a) Create a database for an organization(b) Facilitate sharing of a database by current and future applications(c) Allow sharing application programs(d) Replace file based systems8.5.13 Database is(a) an important resource of an organization(b) not relevant to existing programs(c) not relevant for future programs(d) not as good as files as there is redundancy8.5.14 By data independence we mean application programs(a) do not need data(b) may be developed independent of data(c) may be developed without knowing the organization of data(d) may be developed with independent data

8.5.15 Data independence allows(i) no changes in application programs(ii) change in database without affecting application programs(iii) hardware to be changed without affecting application programs(iv) system software to be changed without affecting application programs(a) i, ii (b) ii, iii(c) ii, iii, iv (d) i, ii, iv

Page 108: Question 1

8.5.16 Data independence allows(a) sharing the same database by several applications(b) extensive modification of applications(c) no data sharing between applications(d) elimination of several application programs

8.5.17 Among objectives of DBMS are ensuring(i) data integrity(ii) data redundancy(iii) data security(iv) easy data retrieval(a) i, ii (b) i, iii(c) i, iii, iv (d) i, ii, iii8.5.18 DBMS(a) does not allow replication of data(b) allows controlled replication of data if it improves performance(c) does not allow common data to be duplicated(d) does not allow replication as it adversely affects reliability8.5.19 By data integrity we mean(a) maintaining consistent data values(b) integrated data values(c) banning improper access to data(d) not leaking data values

Page 109: Question 1

8.5.20 Data integrity is ensured by(a) good data editing(b) propagating data changes to all data items(c) preventing unauthorized access(d) preventing data duplication8.5.21 By data security in DBMS we mean(a) preventing access to data(b) allowing access to data only to authorized users(c) preventing changing data(d) introducing integrity constraints8.5.22 DBMS must implement management controls to(i) control access rights to users(ii) implement audit trail when changes are made(iii) allow data to be used extensively in the organization(iv) duplicate databases(a) i, ii (b) ii, iii(c) iii, iv (d) i, iv

8.5.1 b 8.5.2 a 8.5.3 c 8.5.4 a 8.5.5 d 8.5.6 c 8.5.7 b 8.5.8 a 8.5.9 c 8.5.10 d 8.5.11 c 8.5.12 b 8.5.13 a 8.5.14 c 8.5.15 c 8.5.16 a 8.5.17 c 8.5.18 b 8.5.19 a 8.5.20 b 8.5.21 b 8.5.22 a

Page 110: Question 1

8.6.1 An E-R modelling for given application leads to(a) conceptual data model(b) logical data model(c) external data model(d) internal data model8.6.2 A conceptual data model is converted using a Relational Data BaseManagement System to a(a) logical data model(b) external data model(c) internal data model(d) an entity-relation data model8.6.3 A subset of logical data model accessed by programmers is called a(a) conceptual data model(b) external data model(c) internal data model(d) an entity-relation data model

Page 111: Question 1

8.6.4 When a logical model is mapped into a physical storage such as a disk storethe resultant data model is known as(a) conceptual data model(b) external data model(c) internal data model(d) disk data model8.6.5 A DBMS has the following components(i) a data definition language(ii) a query language(iii) a security system(iv) audit trail(a) i, ii (b) i, ii, iii(c) i, ii, iii, iv (d) i, ii, iv8.6.6 A check pointing system is needed(a) to ensure system security(b) to recover from transient faults(c) to ensure system privacy(d) to ensure system integrity

Page 112: Question 1

8.6.7 A database administrator(a) administers data in an organization(b) controls all inputs and all outputs of programs(c) is controller of data resources of an organization(d) controls all data entry operators8.6.8 The responsibilities of a database administrator includes(i) maintenance of data dictionary(ii) ensuring security of database(iii) ensuring privacy and integrity of data(iv) obtain an E-R model(a) i, ii (b) i, ii, iii(c) i, ii, iii, iv (d) ii, iii, iv8.6.9 Access right to a database is controlled by(a) top management(b) system designer(c) system analyst(d) database administrator8.6.10 The sequence followed in designing a DBMS are(a) physical model conceptual model logical model(b) logical model physical model conceptual model(c) conceptual model logical model physical model(d) conceptual model physical model logical model

Page 113: Question 1

8.6.11 Designing physical model of DBMS requires information on(i) data volume(ii) frequency of access to data(iii) programming language used(iv) secondary memory characteristics(a) i, ii (b) i, ii, iii(c) i, ii, iii, iv (d) i, ii, iv8.6.12A good database design(i) caters primarily to current needs(ii) caters to current and future needs as organizations grow(iii) has to be modified when hardware is upgraded(iv) ensures data security(a) i, ii (b) i, ii, iii(c) ii, iv (d) iii, iv

8.6.13 A good database design(i) is expandable with growth and changes in organization(ii) easy to change when software changes(iii) ensures data integrity(iv) allows access to only authorized users(a) i, ii (b) ii, iii(c) i, ii, iii, iv (d) i, ii, iii

Page 114: Question 1

8.6.1 a 8.6.2 a8.6.3 b 8.6.4 c 8.6.5 c 8.6.6 b 8.6.7 c 8.6.8 b8.6.9 d 8.6.10 c 8.6.11 d 8.6.12 c 8.6.13 c

Page 115: Question 1

1.List the system calls used for process management:

Answer:

System calls Description fork() To create a new process exec() To execute a new program in a process wait() To wait until a created process completes its execution exit() To exit from a process execution getpid() To get a process identifier of the current process getppid() To get parent process identifier nice() To bias the existing priority of a process brk() To increase/decrease the data segment size of a process

Page 116: Question 1

How can you get/set an environment variable from a program? Answer: Getting the value of an environment variable is done by using 'getenv()'. Setting the value of an environment variable is done by using 'putenv()'.How can a parent and child process communicate? Answer: A parent and child can communicate through any of the normal inter-process communication schemes (pipes, sockets, message queues, shared memory), but also have some special ways to communicate that take advantage of their relationship as a parent and child. One of the most obvious is that the parent can get the exit status of the child.What is a zombie? Answer: When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls 'wait()'; In the interval between the child terminating and the parent calling 'wait()', the child is said to be a 'zombie' (If you do 'ps', the child will have a 'Z' in its status field to indicate this.)

Page 117: Question 1

What are the process states in Unix? Answer: As a process executes it changes state according to its circumstances. Unix processes have the following states: Running : The process is either running or it is ready to run . Waiting : The process is waiting for an event or for a resource. Stopped : The process has been stopped, usually by receiving a signal. Zombie : The process is dead but have not been removed from the process table.What Happens when you execute a program? Answer: When you execute a program on your UNIX system, the system creates a special environment for that program. This environment contains everything needed for the system to run the program as if no other program were running on the system. Each process has process context, which is everything that is unique about the state of the program you are currently running. Every time you execute a program the UNIX system does a fork, which performs a series of operations to create a process context and then execute your program in that context. The steps include the following: Allocate a slot in the process table, a list of currently running programs kept by UNIX. Assign a unique process identifier (PID) to the process. iCopy the context of the parent, the process that requested the spawning of the new process. Return the new PID to the parent process. This enables the parent process to examine or control the process directly. After the fork is complete, UNIX runs your program. What Happens when you execute a command? Answer: When you enter 'ls' command to look at the contents of your current working directory, UNIX does a series of things to create an environment for ls and the run it: The shell has UNIX perform a fork. This creates a new process that the shell will use to run the ls program. The shell has UNIX perform an exec of the ls program. This replaces the shell program and data with the program and data for ls and then starts running that new program. The ls program is loaded into the new process context, replacing the text and data of the shell. The ls program performs its task, listing the contents of the current directory. What is a Daemon? Answer: A daemon is a process that detaches itself from the terminal and runs, disconnected, in the background, waiting for requests and responding to them. It can also be defined as the background process that does not belong to a terminal session. Many system functions are commonly performed by daemons, including the sendmail daemon, which handles mail, and the NNTP daemon, which handles USENET news. Many other daemons may exist. Some of the most common daemons are: init: Takes over the basic running of the system when the kernel has finished the boot process. inetd: Responsible for starting network services that do not have their own stand-alone daemons. For example, inetd usually takes care of incoming rlogin, telnet, and ftp connections. cron: Responsible for running repetitive tasks on a regular schedule.

Page 118: Question 1

What is 'ps' command for? Answer: The ps command prints the process status for some or all of the running processes. The information given are the process identification number (PID),the amount of time that the process has taken to execute so far etc.How would you kill a process? Answer: The kill command takes the PID as one argument; this identifies which process to terminate. The PID of a process can be got using 'ps' command.What is an advantage of executing a process in background? Answer: The most common reason to put a process in the background is to allow you to do something else interactively without waiting for the process to complete. At the end of the command you add the special background symbol, &. This symbol tells your shell to execute the given command in the background. Example:cp *.* ../backup& (cp is for copy)

Page 119: Question 1

How do you execute one program from within another? Answer: The system calls used for low-level process creation are execlp() and execvp(). The execlp call overlays the existing program with the new one , runs that and exits. The original program gets back control only when an error occurs. execlp(path,file_name,arguments..); //last argument must be NULL A variant of execlp called execvp is used when the number of arguments is not known in advance. execvp(path,argument_array); //argument array should be terminated by NULLWhat is IPC? What are the various schemes available? Answer: The term IPC (Inter-Process Communication) describes various ways by which different process running on some operating system communicate between each other. Various schemes available are as follows: Pipes: One-way communication scheme through which different process can communicate. The problem is that the two processes should have a common ancestor (parent-child relationship). However this problem was fixed with the introduction of named-pipes (FIFO). Message Queues : Message queues can be used between related and unrelated processes running on a machine. Shared Memory: This is the fastest of all IPC schemes. The memory to be shared is mapped into the address space of the processes (that are sharing). The speed achieved is attributed to the fact that there is no kernel involvement. But this scheme needs synchronization. Various forms of synchronisation are mutexes, condition-variables, read-write locks, record-locks, and semaphores.

Page 120: Question 1

What is the difference between Swapping and Paging? Answer: Swapping: whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems. Paging: Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management? Answer: Historic Unix uses Swapping – entire process is transferred to the main memory from the swap device, whereas the Unix System V uses Demand Paging – only the part of the process is moved to the main memory. Historic Unix uses one Swap Device and Unix System V allow multiple Swap Devices.

Page 121: Question 1

What is the main goal of the Memory Management? Answer: It decides which process should reside in the main memory, Manages the parts of the virtual address space of a process which is non-core resident, Monitors the available main memory and periodically write the processes into the swap device to provide more processes fit in the main memory simultaneously.What is a Map? Answer: A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there. This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map contains one entry – address (block offset from the starting of the swap area) and the total number of resources. Kernel treats each unit of Map as a group of disk blocks. On the allocation and freeing of the resources Kernel updates the Map for accurate information.What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices? Answer: Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V.What is a Region? Answer: A Region is a continuous area of a process's address space (such as text, data and stack). The kernel in a 'Region Table' that is local to the process maintains region. Regions are sharable among the process.

Page 122: Question 1

What are the events done by the Kernel after a process is being swapped out from the main memory? Answer: When Kernel swaps the process out of the primary memory, it performs the following:

Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory, Kernel allocates the space for the swapping process in the swap device, Kernel locks the other swapping process while the current swapping operation is going on, The Kernel saves the swap address of the region in the region table.

Is the Process before and after the swap are the same? Give reason. Answer: Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process out. After swapping the process resides in the swap (secondary memory) device. The regions swapped out will be present but only the occupied region slots but not the empty slots that were present before assigning. While swapping the process once again into the main memory, the Kernel referring to the Process Memory Map, it assigns the main memory accordingly taking care of the empty slots in the regions.What do you mean by u-area (user area) or u-block? Answer: This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area.

Page 123: Question 1

What are the entities that are swapped out of the main memory while swapping the process out of the main memory? Answer: All memory space occupied by the process, process's u-area, and Kernel stack are swapped out, theoretically. Practically, if the process's u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area.What is Fork swap? Answer: fork() is a system call to create a child process. When the parent process calls fork() system call, the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device, and return to the user state without swapping the parent process. When the memory will be available the child process will be swapped into the main memory.

Page 124: Question 1

What is Expansion swap? Answer: At the time when any process requires more memory than it is currently allocated, the Kernel performs Expansion swap. To do this Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later when the Kernel swaps the process into the main memory this assigns memory according to the new address translation mapping.Questions on memory management in uinxHow the Swapper works? Answer: The swapper is the only process that swaps the processes. The Swapper operates only in the Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process.What are the processes that are not bothered by the swapper? Give Reason. Answer: Zombie process: They do not take any up physical memory. Processes locked in memories that are updating the region of the process. Kernel swaps only the sleeping processes rather than the 'ready-to-run' processes, as they have the higher probability of being scheduled than the Sleeping processes.What are the requirements for a swapper to work? Answer: The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if not found then it will look for the ready-to-run process for swapping. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds before swapping out. And for swapping in the process must have been resided in the swap device for at least 2 seconds. If the requirement is not satisfied then the swapper will go into the wait state on that event and it is awaken once in a second by the Kernel.

Page 125: Question 1

What are the criteria for choosing a process for swapping into memory from the swap device? Answer: The resident time of the processes in the swap device, the priority of the processes and the amount of time the processes had been swapped out.What are the criteria for choosing a process for swapping out of the memory to the swap device? Answer: The process's memory resident time, Priority of the process and The nice value.What do you mean by nice value? Answer: Nice value is the value that controls {increments or decrements} the priority of the process. This value that is returned by the nice () system call. The equation for using nice value is: Priority = ("recent CPU usage"/constant) + (base- priority) + (nice value) Only the administrator can supply the nice value. The nice () system call works for the running process only. Nice value of one process cannot affect the nice value of the other process.What are conditions on which deadlock can occur while swapping the processes? Answer: All processes in the main memory are asleep. All 'ready-to-run' processes are swapped out. There is no space in the swap device for the new incoming process that are swapped out of the main memory. There is no space in the main memory for the new incoming process.

Page 126: Question 1

What are conditions for a machine to support Demand Paging? Answer: Memory architecture must based on Pages, The machine must support the 'restartable' instructions.What is 'the principle of locality'? Answer: It's the nature of the processes that they refer only to the small subset of the total data space of the process. i.e. the process frequently calls the same subroutines or executes the loop instructions.What is the working set of a process? Answer: The set of pages that are referred by the process in the last 'n', references, where 'n' is called the window of the working set of the process.What is the window of the working set of a process? Answer: The window of the working set of a process is the total number in which the process had referred the set of pages in the working set of the process.

Page 127: Question 1

What is called a page fault? Answer: Page fault is referred to the situation when the process addresses a page in the working set of the process but the process fails to locate the page in the working set. And on a page fault the kernel updates the working set by reading the page from the secondary device.What are data structures that are used for Demand Paging? Answer: Kernel contains 4 data structures for Demand paging. They are,

Page table entries, Disk block descriptors, Page frame data table (pfdata), Swap-use table.

What are the bits that support the demand paging? Answer: Valid, Reference, Modify, Copy on write, Age. These bits are the part of the page table entry, which includes physical address of the page and protection bits.

Page 128: Question 1

How the Kernel handles the fork() system call in traditional Unix and in the System V Unix, while swapping? Answer: Kernel in traditional Unix, makes the duplicate copy of the parent's address space and attaches it to the child's process, while swapping. Kernel in System V Unix, manipulates the region tables, page table, and pfdata table entries, by incrementing the reference count of the region table of shared regions.Difference between the fork() and vfork() system call? Answer: During the fork() system call the Kernel makes a copy of the parent process's address space and attaches it to the child process. But the vfork() system call do not makes any copy of the parent's address space, so it is faster than the fork() system call. The child process as a result of the vfork() system call executes exec() system call. The child process from vfork() system call executes in the parent's address space (this can overwrite the parent's data and stack ) which suspends the parent process until the child process exits.What is BSS(Block Started by Symbol)? Answer: A data representation at the machine level, that has initial values when a program starts and tells about how much space the kernel allocates for the un-initialized data. Kernel initializes it to zero at run-time.What is Page-Stealer process? Answer: This is the Kernel process that makes rooms for the incoming pages, by swapping the memory pages that are not the part of the working set of a process. Page-Stealer is created by the Kernel at the system initialization and invokes it throughout the lifetime of the system. Kernel locks a region when a process faults on a page in the region, so that page stealer cannot steal the page, which is being faulted in.Name two paging states for a page in memory? Answer: The two paging states are: The page is aging and is not yet eligible for swapping, The page is eligible for swapping but not yet eligible for reassignment to other virtual address space.

Page 129: Question 1

What are the phases of swapping a page from the memory? Answer: Page stealer finds the page eligible for swapping and places the page number in the list of pages to be swapped. Kernel copies the page to a swap device when necessary and clears the valid bit in the page table entry, decrements the pfdata reference count, and places the pfdata table entry at the end of the free list if its reference count is 0.What is page fault? Its types? Answer: Page fault refers to the situation of not having a page in the main memory when any process references it. There are two types of page fault : Validity fault, Protection fault. In what way the Fault Handlers and the Interrupt handlers are different? Answer: Fault handlers are also an interrupt handler with an exception that the interrupt handlers cannot sleep. Fault handlers sleep in the context of the process that caused the memory fault. The fault refers to the running process and no arbitrary processes are put to sleep.What is validity fault? Answer: If a process referring a page in the main memory whose valid bit is not set, it results in validity fault. The valid bit is not set for those pages: that are outside the virtual address space of a process, that are the part of the virtual address space of the process but no physical address is assigned to it.

Page 130: Question 1

What does the swapping system do if it identifies the illegal page for swapping? Answer: If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a "Segmentation violation" signal to the offending process. This happens when the swapping system identifies any invalid memory reference.What are states that the page can be in, after causing a page fault? Answer: On a swap device and not in memory, On the free page list in the main memory, In an executable file, Marked "demand zero", Marked "demand fill". In what way the validity fault handler concludes? Answer: It sets the valid bit of the page by clearing the modify bit. It recalculates the process priority.At what mode the fault handler executes? Answer: At the Kernel Mode.What do you mean by the protection fault? Answer: Protection fault refers to the process accessing the pages, which do not have the access permission. A process also incur the protection fault when it attempts to write a page whose copy on write bit was set during the fork() system call.

Page 131: Question 1

How the Kernel handles the copy on write bit of a page, when the bit is set? Answer: In situations like, where the copy on write bit of a page is set and that page is shared by more than one process, the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page. After copying the Kernel updates the page table entry with the new page number. Then Kernel decrements the reference count of the old pfdata table entry. In cases like, where the copy on write bit is set and no processes are sharing the page, the Kernel allows the physical page to be reused by the processes. By doing so, it clears the copy on write bit and disassociates the page from its disk copy (if one exists), because other process may share the disk copy. Then it removes the pfdata table entry from the page-queue as the new copy of the virtual page is not on the swap device. It decrements the swap-use count for the page and if count drops to 0, frees the swap space.For which kind of fault the page is checked first? Answer: The page is first checked for the validity fault, as soon as it is found that the page is invalid (valid bit is clear), the validity fault handler returns immediately, and the process incur the validity page fault. Kernel handles the validity fault and the process will incur the protection fault if any one is present.In what way the protection fault handler concludes? Answer: After finishing the execution of the fault handler, it sets the modify and protection bits and clears the copy on write bit. It recalculates the process-priority and checks for signals.

Page 132: Question 1

How the Kernel handles both the page stealer and the fault handler? Answer: The page stealer and the fault handler thrash because of the shortage of the memory. If the sum of the working sets of all processes is greater that the physical memory then the fault handler will usually sleep because it cannot allocate pages for a process. This results in the reduction of the system throughput because Kernel spends too much time in overhead, rearranging the memory in

Predict the output or error(s) for the following: void main(){

int const * p=5;printf("%d",++(*p));

}Answer:Compiler error: Cannot modify a constant value.Explanation: p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

Page 133: Question 1

main(){

char s[ ]="man";int i;for(i=0;s[ i ];i++)printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);

}Answer: mmmm aaaa nnnnExplanation: s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].main(){

float me = 1.1;double you = 1.1;if(me==you)

printf("I love U");else

printf("I hate U");}Answer: I hate UExplanation: For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.Rule of Thumb: Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ).

Page 134: Question 1

main(){static int var = 5;printf("%d ",var--);if(var)main();

} Answer: 5 4 3 2 1Explanation: When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.main(){ int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) {printf(" %d ",*c); ++q; } for(j=0;j<5;j++){printf(" %d ",*p);++p; }} Answer: 2 2 2 2 2 2 3 4 6 5Explanation: Initially pointer c is assigned to both p and q. In the first loop, since only q is incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.

Page 135: Question 1

main(){extern int i;i=20;printf("%d",i);} Answer: Linker Error : Undefined symbol '_i'Explanation: extern storage class in the following declaration, extern int i; specifies to the compiler that the memory for i is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name i is available in any other program with memory space allocated for it. Hence a linker error has occurred . main(){ int i=-1,j=-1,k=0,l=2,m;m=i++&&j++&&k++||l++;printf("%d %d %d %d %d",i,j,k,l,m);} Answer: 0 0 1 3 1Explanation : Logical operations always give a result of 1 or 0 . And also the logical AND (&&) operator has higher priority over the logical OR (||) operator. So the expression 'i++ && j++ && k++' is executed first. The result of this expression is 0 (-1 && -1 && 0 = 0). Now the expression is 0 || 2 which evaluates to 1 (because OR operator always gives 1 except for '0 || 0' combination- for which it gives 0). So the value of m is 1.

Page 136: Question 1

other var{ char *p;printf("%d %d ",sizeof(*p),sizeof(p));

}Answer: 1 2Explanation: The sizeof() operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof(p) gives 2.

main(){int i=3;

switch(i) { default:printf("zero"); case 1: printf("one");

break; case 2:printf("two");

break; case 3: printf("three");

break; }

}Answer : threeExplanation : The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.

Page 137: Question 1

main(){

printf("%x",-1<<4);}Answer: fff0Explanation : -1 is internally represented as all 1's. When left shifted four times the least significant 4 bits are filled with 0's.The %x format specifier specifies that the integer value be printed as a hexadecimal value.main(){

char string[]="Hello World";display(string);

}void display(char *string){

printf("%s",string);}Answer: Compiler Error : Type mismatch in redeclaration of function displayExplanation : In third line, when the function display is encountered, the compiler doesn't know anything about the function display. It assumes the arguments and return types to be integers, (which is the default type). When it sees the actual function display, the arguments and type contradicts with what it has assumed previously. Hence a compile time error occurs. iables are also incremented by 1.

Page 138: Question 1

main(){

int c=- -2;printf("c=%d",c);

}Answer: c=2;Explanation: Here unary minus (or negation) operator is used twice. Same maths rules applies, ie. minus * minus= plus.Note:However you cannot give like --2. Because -- operator can only be applied to variables as a decrement operator (eg., i--). 2 is a constant and not a variable. #define int charmain(){

int i=65;printf("sizeof(i)=%d",sizeof(i));

}Answer: sizeof(i)=1Explanation: Since the #define replaces the string int by the macro char

Page 139: Question 1

main(){int i=10;i=!i>14;printf("i=%d",i);}Answer: i=0Explanation: In the expression !i>14 , NOT (!) operator has more precedence than ‘ >’ symbol. ! is a unary logical operator. !i (!10) is 0 (not of true is false). 0>14 is false (zero). #include‹stdio.h›main(){char s[]={'a','b','c','\n','c','\0'};char *p,*str,*str1;p=&s[3];str=p;str1=s;printf("%d",++*p + ++*str1-32);}Answer: 77Explanation: p is pointing to character '\n'. str1 is pointing to character 'a' ++*p. "p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10, which is then incremented to 11. The value of ++*p is 11. ++*str1, str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98. Now performing (11 + 98 - 32), we get 77("M"); So we get the output 77 :: "M" (Ascii is 77).

Page 140: Question 1

#include‹stdio.h›main(){int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };int *p,*q;p=&a[2][2][2];*q=***a;printf("%d----%d",*p,*q);}Answer: SomeGarbageValue---1Explanation: p=&a[2][2][2] you declare only two 2D arrays, but you are trying to access the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of a is assigned integer pointer. Now q is pointing to starting address of a. If you print *q, it will print first element of 3D array.#include‹stdio.h›main(){struct xx{ int x=3; char name[]="hello"; };struct xx *s;printf("%d",s->x);printf("%s",s->name);}Answer: Compiler ErrorExplanation: You should not initialize variables in declaration

Page 141: Question 1

#include‹stdio.h›main(){struct xx{int x;struct yy{char s;

struct xx *p;};struct yy *q;};}Answer: Compiler ErrorExplanation: The structure yy is nested within structure xx. Hence, the elements are of yy are to be accessed through the instance of structure xx, which needs an instance of yy to be known. If the instance is created after defining the structure the compiler will not know about the instance relative to xx. Hence for nested structure yy you have to declare member. main(){printf("\nab");printf("\bsi");printf("\rha");}Answer: haiExplanation: \n - newline \b - backspace \r - linefeed

Page 142: Question 1

main(){int i=5;printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);}Answer: 45545Explanation: The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result. #define square(x) x*xmain(){int i;i = 64/square(4);printf("%d",i);}Answer: 64Explanation: the macro call square(4) will substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64

Page 143: Question 1

main(){char *p="hai friends",*p1;p1=p;while(*p!='\0') ++*p++;printf("%s %s",p,p1);}Answer: ibj!gsjfoetExplanation: ++*p++ will be parse in the given order

*p that is value at the location currently pointed by p will be taken ++*p the retrieved value will be incremented when ; is encountered the location will be incremented that is p++ will be executed

Hence, in the while loop initial value pointed by p is 'h', which is changed to 'i' by executing ++*p and pointer moves to point, 'a' which is similarly changed to 'b' and so on. Similarly blank space is converted to '!'. Thus, we obtain value in p becomes “ibj!gsjfoet†and since p reaches '\0' and p1 points to p thus p1doesnot print anything.�#include‹stdio.h›#define a 10main(){#define a 50printf("%d",a);}Answer:50Explanation:The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value will be taken.

Page 144: Question 1

#define clrscr() 100main(){clrscr();printf("%d\n",clrscr());}Answer:100Explanation:Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :

main(){ 100; printf("%d\n",100);}

Note:100; is an executable statement but with no action. So it doesn't give any problemmain(){printf("%p",main);}Answer:Some address will be printed.Explanation:Function names are just addresses (just like array names are addresses).

Page 145: Question 1

main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers. main() {clrscr();}clrscr();Answer: No output/errorExplanation: The first clrscr() occurs inside a function. So it becomes a function call. In the second clrscr(); is a function declaration (because it is not inside any function).enum colors {BLACK,BLUE,GREEN} main(){ printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1);}Answer: 0..1..2Explanation: enum assigns numbers starting from 0, if not explicitly defined. void main(){ char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }Answer: 4..2Explanation: the second pointer is of char type and not a far pointer

Page 146: Question 1

main(){ int i=400,j=300; printf("%d..%d");}Answer: 400..300Explanation: printf takes the values of the first two assignments of the program. Any number of printf's may be given. All of them take only the first two values. If more number of assignments given in the program,then printf will take garbage values.main(){ char *p; p="Hello"; printf("%c\n",*&*p);}Answer: HExplanation: * is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H.

Page 147: Question 1

main(){ int i=1; while (i<=5) { printf("%d",i); if (i>2)

goto here; i++; }}fun(){ here: printf("PP");}Answer: Compiler error: Undefined label 'here' in function mainExplanation: Labels have functions scope, in other words The scope of the labels is limited to functions . The label 'here' is available in function fun() Hence it is not visible in function main.main(){ static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]);}Answer: Compiler error: Lvalue required in function mainExplanation: Array names are pointer constants. So it cannot be modified.

Page 148: Question 1

void main(){

int i=5;printf("%d",i++ + ++i);

}Answer: Output Cannot be predicted exactly.Explanation: Side effects are involved in the evaluation of ivoid main(){

int i=5;printf("%d",i+++++i);

}Answer: Compiler ErrorExplanation: The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.#include‹stdio.h›main(){int i=1,j=2;switch(i) { case 1: printf("GOOD");

break; case j: printf("BAD"); break; }}Answer: Compiler Error: Constant expression required in function main.Explanation: The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).Note: Enumerated types can be used in case statements

Page 149: Question 1

main(){int i;printf("%d",scanf("%d",&i)); // value 10 is given as input here}Answer: 1Explanation: Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.#define f(g,g2) g##g2main(){int var12=100;printf("%d",f(var,12));

}Answer: 100main(){int i=0; for(;i++;printf("%d",i)) ;printf("%d",i);}Answer: 1Explanation: before entering into the for loop the checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).

Page 150: Question 1

#include‹stdio.h›main(){ char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32);}Answer: MExplanation: p is pointing to character '\n'.str1 is pointing to character 'a' ++*p meAnswer:"p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10. then it is incremented to 11. the value of ++*p is 11. ++*str1 meAnswer:"str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98. both 11 and 98 is added and result is subtracted from 32". i.e. (11+98-32)=77("M");#include‹stdio.h›main(){ struct xx { int x=3; char name[]="hello"; };struct xx *s=malloc(sizeof(struct xx));printf("%d",s->x);printf("%s",s->name);}Answer: Compiler ErrorExplanation: Initialization should not be done for structure members inside the structure declaration

Page 151: Question 1

include‹stdio.h›main(){struct xx {

int x; struct yy { char s; struct xx *p; };

struct yy *q; }; }Answer: Compiler ErrorExplanation: in the end of nested structure yy a member have to be declared.main(){ extern int i; i=20; printf("%d",sizeof(i));}Answer: Linker error: undefined symbol '_i'.Explanation: extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.

Page 152: Question 1

main(){printf("%d", out);}int out=100;Answer: Compiler error: undefined symbol out in function main.Explanation: The rule is that a variable is available for use from the point of declaration. Even though a is a global variable, it is not available for main. Hence an error.main(){ extern out; printf("%d", out);} int out=100;Answer: 100Explanation: This is the correct way of writing the previous program.main(){ show();}void show(){ printf("I'm the greatest");}Answer: Compier error: Type mismatch in redeclaration of show.Explanation: When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error. The solutions are as follows:

declare void show() in main() . define show() before main(). declare extern void show() before the use of show().

Page 153: Question 1

Predict the output or error(s) for the following: class Sample{public: int *ptr; Sample(int i) { ptr = new int(i); } ~Sample() { delete ptr; } void PrintVal() { cout « "The value is " « *ptr; }};void SomeFunc(Sample x){cout « "Say i am in someFunc " « endl;}int main(){Sample s1= 10;SomeFunc(s1);s1.PrintVal();}Answer: Say i am in someFunc Null pointer assignment(Run-time error)Explanation: As the object is passed by value to SomeFunc the destructor of the object is called when the control returns from the function. So when PrintVal is called it meets up with ptr that has been freed.The solution is to pass the Sample object by reference to SomeFunc:void SomeFunc(Sample &x){cout « "Say i am in someFunc " « endl;}because when we pass objects by refernece that object is not destroyed. while returning from the function.

Page 154: Question 1

Which is the parameter that is added to every non-static member function when it is called? Answer: 'this' pointer class base { public: int bval; base(){ bval=0;} };class deri:public base { public: int dval; deri(){ dval=1;} };void SomeFunc(base *arr,int size){for(int i=0; i‹size; i++,arr++) cout«arr-›bval;cout«endl;}int main(){base BaseArr[5];SomeFunc(BaseArr,5);deri DeriArr[5];SomeFunc(DeriArr,5);}Answer: 00000 01010Explanation: The function SomeFunc expects two arguments.The first one is a pointer to an array of base class objects and the second one is the sizeof the array.The first call of someFunc calls it with an array of bae objects, so it works correctly and prints the bval of all the objects. When Somefunc is called the second time the argument passed is the pointeer to an array of derived class objects and not the array of base class objects. But that is what the function expects to be sent. So the derived class pointer is promoted to base class pointer and the address is sent to the function. SomeFunc() knows nothing about this and just treats the pointer as an array of base class objects. So when arr++ is met, the size of base class object is taken into consideration and is incremented by sizeof(int) bytes for bval (the deri class objects have bval and dval as members and so is of size ›= sizeof(int)+sizeof(int)

Page 155: Question 1

You install File and Printer Sharing for Microsoft Networks.You share a folder and leave the password option blank.Who can gain access to the folder

a. Anyone who can gain access to your network and has a Microsoft redirector such as the Client for Microsoft Networks installed.

b.Windows 98 will not allow a blank password in this field. c.anyone with Internet Explorer installed. d.Only users that are members of the same workgroup as you.

Answer: A Some protocols are considered to be technically non-routable.Which of the following statements best

describes the most common reason why a protocol would be considered non-routable A. It does not contain the appropriate Data Link layer information required by routers.

B. It uses advanced Transport layer services to move across the Internet and avoids the routing overhead required by the more primitive networking protocols.

c.It defines Physical layer network addresses for internal routing. D.It does not specify the Network layer addresses required by routers.

Answer: D What is the binary network ID of the loopback IP address

A. 1 B. 10101010 C. 0 D. 1111111

Answer: D

Page 156: Question 1

You are the LAN administrator for your company.You have couple Windows 2000 Professional clients that dial in via PPP to the company network’s RAS server.You want the remote clients to be assigned dynamic IP addresses.You reserve a pool of class B addresses for these clients.Upon connecting, you find that the Windows 2000 computers are using a subnet mask of all 255s.What should you do

A. Run ipconfig with the /release and /renew switch on the client B. Run ipconfig with the /renew_all switch on the client C. Run winipcfg on the client D. Do nothing.This is normal

Answer: D

You are configuring a router.According to the manual, you will need a transceiver to connect to the LAN ports of the router.What kind of physical interface does the router have A. MSAU B. RJ-11 C. AUI D. BNC

Answer: C

Page 157: Question 1

Which of the following are connectionless protocols.(Choose the three best answers.) A. IP B. SPX C. IPX D. UDP

Answer: A, C, D How can Jim Herr, a client on an NT TCP/IP network see which remote hosts are currently connected using NBT

A. Use NBTSTAT B. Use NETSTAT C. Use NSLOOKUP D. Use IPCONFIG

Answer: A You are setting up a new Windows 98 workstation on your network, and your DHCP server provides all of the

normal TCP/IP configuration information.What must you do to configure the IP address on the workstation after you add the TCP/IP protocol

A. The DHCP option is enabled automatically, and the server will auto-configure everything. B. Find out what the subnet mask on your network is, and add this information only. C. Manually enter an IP address that is not in use on the network. D. Put the address of the router in the default gateway, and put all 0s in the IP field.

Answer: A Which of the following is considered a Network Attached Storage device

A. A 60 GB DAT tape drive attached to the Network Server B. A file server with special software that is at a separate location from the departmental file server C. In a Windows NT environment, it would be the Backup Domain Controller D. A high speed specialized sub-network attached to the enterprise

Answer: B

Page 158: Question 1

Credit card size, designed for notebooks, self-configuring, and non-OS dependent describes which PC bus architecture

A. PCI B. ISA C. EISA D. PCMCIA

Answer: D What protocol is used between E-Mail servers

A. HTTP B. POP3 C. SNMP D. SMTP

Answer: D When installing a manually configured adapter, what information must you know to avoid resource conflicts

A. IRQ B. Number of bits C. Base I/O port address D. Base Memory address

Answer: A, C & D Which of the following OSI layers is responsible for identifying communications partners

A. Application B. Session C. Network D. Presentation

Answer: A A broadcast message is an example of which dialog control method

A. Half duplex B. Baseband C. Broadband D. Simplex

Answer: D

Page 159: Question 1

A. Which of the following are used to resolve Windows NetBIOS names to IP addresses A. DNS B. WINS C. LMhosts file D. Hosts file

Answer: B,C What is a router

A. A hardware device that connects dissimilar networks, such as Cat 5 cabling and FDDI B. A network host that reads the source and destination addresses in the packet header and makes

decisions about where to forward the packet C. A network host that can forward LAN-based email messages onto the Internet, after repackaging

them into the SMTP format D. A software system that can translate between dissimilar networks such as Ethernet and Token

Ring Answer: B Which of the following is Class C IP address?

A. 10.10.14.118 B. 135.23.112.57 C. 191.200.199.199 D. 204.67.118.54

Answer: D

Page 160: Question 1

A Windows 95 user complains that she cannot connect to any other computers on her local subnet even when using the IP address to communicate.However, she can ping 127.0.0.1 and receive a reply.Other users on her subnet do not report having any trouble.All client computers on the network are WINS-enabled.What is the most probable cause of the problem?

A. The TCP/IP stack is not installed properly B. The subnet mask is not correct, check whether the subnet mask is configured correctly. C. The default gateway is not configured properly. D. The computer is not configured to use LMHOSTS

Answer: B WINS or ___ may be used for NetBIOS name resolution?

A. HOSTS B. DNS C. LMHOSTS

Answer: C You have set up a server that connects to an Internet services provider ( ISP) over ISDN line.How should the default gateway address be configured so that windows

95 users on the local network can access the Internet through the RAS server.The RAS server is located on the same subnet as that of the WIN95 machines. A. The default Gateway address on WINS95 must specify the IP address of the remote ISP B. The default Gateway on WN95 must specify the IP address of the RAS server on the local network. C. The HOSTS file in WIN95 machines must be configured with the host name of the RAS Server. D. The HOSTS file in WIN 95 machines must be configured with the host name of the ISP

Answer: B Which of the following is the standard adopted for Ethernet CSMA/CD by IEEE Committee?

A. 802.2 B. 802.1d C. 802.3 D. 802.5

Answer: C Disk Striping with Parity corresponds to which RAID level?

A. RAID 0 B. RAID 1 C. RAID 3 D. RAID 5

Answer: D. Which of the following media types is most susceptible to EMI?

A. Fiber Optic B. STP C. Co-axial D. UTP

Answer: D

Page 161: Question 1

Which type of connector does a 10BaseT Ethernet cable use? A. BNC B. RJ-45 C. RJ-11 D. MSAU

Answer: B Which of the following is suitable for mission critical and time sensitive applications?

A. 10BaseT B. 10Base2 C. Token Ring D. Mesh

Answer: C What is the default subnet mask for Class C network?

A. 255.0.0.0 B. 255.255.0.0 C. 255.255.255.0 D. 255.0.255.0

Answer: C Which of the following network topologies have each computer connected to a central point?

A. Bus B. Ring C. Star D. Mesh

Answer: C Which of the following network topologies is the most fault tolerant?

A. Bus B. Mesh C. Star D. Ring

Answer: B A Bus network topology is best described as which of the following?

A. All computers are attached to a single cable in a chain style B. All computers are connected to a central point C. All computers are connected to every other computer or resource in the network D. Fault Tolerant

Answer: A A Ring network topology provides two links from each computer.A link in and a link out.

A. True B. False

Answer:A

Page 162: Question 1

Which connector is often used with Thinnet cable? A. RJ-11 B. AUI C. DIX D. BNC

Answer:D Which of the following media connectors are used in conjunction with telephones?

A. RJ-45 B. RJ-11 C. RJ-T D. None of the above are correct

Answer:B 10BaseT Ethernet networks, most commonly use which of the following types of cable?

A. Fiber B. Coax C. STP D. UTP

Answer:D A Gateway is able to connect network environments that are dissimilar.

A. True B. False

Answer:A AUI connectors are commonly associated with which of the following items?

A. A Vampire Tap B. Fiber Optic Cable C. 10Base2 D. Wireless Networks

Answer:A A hub works in conjunction with which of the following network topologies?

A. Ring B. Star C. Bus D. Mesh

Answer:B Which of the following is a correct MAC address?

A. 190.168.80.1 B. www.certyourself.com C. 08:34:FE:4C:F2:54 D. G2:G3:23:87:GG

Answer:C A Hub operates at which of the following layers of the OSI model?

A. Physical B. Session C. Transport D. Application

Answer:A

Page 163: Question 1

• A Router operates in which layer of the OSI model?

A. The Physical Layer B. The Data Link Layer C. The Transport Layer D. The Network Layer

• Answer:D • A Network Interface Card operates at the

Network Layer of the OSI model. A. True B. False

• Answer:B • Which of the following is the correct order of

the OSI model from bottom to top? A. Application, Presentation, Session,

Transport, Network, Data Link, Physical B. Physical, Network, Data Link, Session,

Transport, Application, Presentation C. Physical, Data Link, Network, Transport,

Session, Presentation, Application D. Application, Session, Presentation,

Transport, Network, Data Link, Physical • Answer:C • What is the maximum speed of 10Base5

Ethernet cable? A. 100 Mbps B. 500 Mbps C. 50 Mbps D. 10 Mbps

• Answer:D

• 100Base-FX uses which of the following types of cable?

A. Fiber Optic B. Unshielded Twisted Pair C. Coax D. Shielded Twisted Pair

• Answer:A • Which of the following TCP/IP protocols is used

to communicate between a Web Browser and a Web Server?

A. SMTP B. HTTP C. UDP D. POP3

• Answer:B • Which of the following layers of the OSI model

does a Bridge operate in? A. The Data Link Layer B. The Network Layer C. The Transport Layer D. The Session Layer

• Answer:A • While reviewing the security logs for your

server, you notice that a user on the Internet has attempted to access your internal mail server.Although it appears that the user's attempts were unsuccessful, you are still very concerned about the possibility that your systems may be compromised.Which of the following solutions are you most likely to implement?

A. A firewall system at the connection point to the Internet B. A more secure password policy C. File-level encryption D. Kerberos authentication

• Answer: A

Page 164: Question 1

• A server has two NIC cards installed.The first one uses IRQ 10 and I/O range of B800-B81F.The second uses IRQ 10 and I/O range of D700-D80A.What action, if any, should be taken?

A. No action is required. B. Locate any available IRQ to resolve the IRQ conflict. C. Locate any available I/O range to resolve the I/O

conflict. D. Change the I/O of the second NIC to B800-B81F.

• Answer: B • Which of the following IEEE 802 standards

pertain to token ring? A. IEEE 802.5 B. IEEE 802.3 C. IEEE 802.2 D. IEEE 802.11

• Answer: A • Protocol that is often used to facilitate

communications with an IBM mainframe? A. NetBEUI B. RIP C. DLC

• Answer: C • Which of these protocols provide fast

connectionless communications that relies on upper layers of the OSI model for error correction?

A. TCP (Transmission Control Protocol) B. UDP (User Datagram Protocol) C. SPX

• Answer: B

• Can be used to reduce traffic bottlenecks in a NetBEUI network?

A. bridge B. router C. gateway

• Answer: A • You have just finished the installation of two

computers on a 28 computer network using Novell's IPX/SPX.Both computers initialize with no error messages yet they cannot contact other computers on the network.All other computers are functioning normally.You probably have an ___?

A. incorrect IRQ B. incorrect frame type C. invalid IP setting

• Answer: B • Uses amplifiers to regenerate analog signals?

A. baseband B. broadband C. fiber-optic

• Answer: B • Uses single frequency digital signals?

A. baseband B. broadband C. multiband

• Answer: A • You are hired to investigate a slow performing

network server for a client.Using the performance monitor you obtain the following readings: CPU usage= 25%, Disk time= 25%, Page faults/sec= 25.What one change will increase the performance of this network server the most?

A. buy another CPU B. add another hard drive C. increase RAM

• Answer: C

Page 165: Question 1

A. Which of the following should you check if you can connect using the IP address but NOT with the host name?

A. DNS B. WINS C. DHCP

• Answer: A • The fastest method of transporting data with a switch?

A. store and forward B. cut through C. loop back

• Answer: B • Although NOT fault tolerant this RAID level is often

used when one wants the highest level of performance?

A. RAID 0 B. RAID 1 C. RAID 5

• Answer: A • Four _____ are used in the 5-4-3 rule of 10Base2

networking? A. repeaters B. segments C. routers

• Answer: A • You have just finished installing an Ethernet PCI NIC

(network interface card) in a client's computer.The computer initializes successfully and has no apparent hardware problems.The computer however is not able to communicate with other computers on this NetBEUI network.All other client computers are able to communicate.What is the most likely cause of this problem?

A. IRQ conflict B. incorrect transceiver setting C. incorrect frame type

• Answer: B

• The two key components of a digital signature include the secure hash algorithm and a ___ ?

A. blowfish value B. certificate authority C. IPSec

• Answer: B • The Microsoft version of Novell's IPX/SPX protocol?

A. ODI B. NWLink C. DLC

• Answer: B • Utility used to run applications on a computer at a remote

location? A. ODI B. Telnet C. ARP (Address Resolution Protocol)

• Answer: B • Topology that offers the highest level of redundancy, is

easy to troubleshoot but is expensive to install.It is the topology of the internet?

A. star B. ring C. mesh

• Answer: C

Page 166: Question 1

• Ordinary telephone wire has a thickness of AWG 22.Of the following which is the thickest

wire?

A. AWG 14 B. AWG 28 C. AWG 32

• Answer: A • Backup method which clears the archive bit and is the shortest to perform but takes the

longest to restore?

A. full B. incremental C. differential

• Answer: B • Which of the following protocols map a logical address to a MAC (Media Access Control)

address?

A. DNS B. WINS C. ARP

• Answer: C • The major limiting factor for how long a cable can be in a segment is ___?

A. collisions B. EMI C. attenuation

• Answer: C • « Previous || Next »• Backing up the system state in Win 2000 Prof will backup the ___?

A. registry B. boot files C. all of the above

• Answer: C • Equipment that is designed to help identify breaks and shorts in cables?

A. TDR B. performance monitor C. SNMP

• Answer: A • Which company developed the Unix Operating System?

A. Sun B. Microsoft C. ATT

• Answer: C

• To start a Win 2000 Prof computer in the safe mode press ___ at startup?

A. F8 B. Ctl and Esc C. F1

• Answer: A • A bridge filters traffic using which type of address?

A. IP address B. MAC address C. TCP address

• Answer: B • A large network with 500 users notice that at specific times in the morning and afternoon

network congestion ties up their computers.What is the most likely cause?

A. power fluctuations B. a terminator is not grounded C. many users are logging on or off

• Answer: C • A ___ is created when a unique IP address and port number are used to connect two

computers?

A. SAP B. media transfer coefficient C. socket

• Answer: C • During disaster recovery of a Win 2000 Prof computer if you "Enable Boot Logging" the file

___ is saved to the C:\winnt folder for analysis?

A. setuplog.txt B. bootlog.txt ntbtlog.txt

• Answer: C • Which of these WAN (Wide Area Network) protocols is the fastest?

A. Frame Relay B. ATM C. X.25

• Answer: B • The only files on a Win 2000 Prof Emergency Repair Disk (ERD) are autoexec.nt, config.nt,

and setup.log?

A. True B. False

• Answer: A • OSI layer responsible for mail and file transfers?

A. transport B. data link C. application

• Answer: C

Page 167: Question 1

• A protocol that functions at the network layer of the OSI model?

A. TCP B. IP C. SPX

• Answer: B • A major advantage of ___ in an NT network is centralized security and

administration?

A. user-level security B. share-level security C. RAID 5

• Answer: A • OC-1 has a transmission rate that is close to ___ ?

A. T-1 B. T-3 C. ISDN

• Answer: B

•The maximum number of populated segments allowed in an Ethernet network?

A. 3 B. 4 C. 5

• Answer: A • Using the TCP/IP protocol if the destination of the packet is outside the subnet then

the packet is sent to the ___?

A. switch B. bridge C. default gateway

• Answer: C • Entry in DNS to identify your mail server?

A. IDC B. TU C. MX

• Answer: C • Toplology which is the least expensive to install?

A. ring B. star C. bus

• Answer: C

• Utility which can be used to identify bottlenecks in the network?

A. PING B. WINIPCFG C. TRACERT

• Answer: C • What is the first octet range for a class A IP address?

A. 1- 126 B. 1- 128 C. 1- 191

• Answer: A • After you setup the IP address and subnet mask your FIRST test should be with ___?

A. tracert to a known good server B. ping 127.0.0.1 C. ping another computer on your segment

• Answer: B • NetBIOS computer names can have up to ___ characters?

A. 256 B. 15 C. 20

• Answer: B • Refers to the part of the network that is separated by routers, bridges, or switches?

A. partition B. node C. segment

• Answer: C • Data is organized into FRAMES for transmission at this OSI level?

A. physical B. data-link C. network

• Answer: B • 10Base2 coaxial has a limit of ___ computers per segment?

A. 2 B. 30 C. 100

• Answer: B

Page 168: Question 1

• Cable used for ArcNet networks? A. RG-58 B. RG-59 C. RG-62

• Answer: C • A Class A IP address uses the last ___

octet(s) for the host ID.The host ID is the unique part and identifies the individual user and part of the reason 50% of all IP addresses are Class A?

A. one B. two C. three

• Answer: C • Of the three (3) RAID levels used by a

Win 2000 server choose the one(s) that is/are fault tolerant?

A. 0, 1, and 5 B. 1 and 5 C. 5

• Answer: B • The best method to restore the latest

copy of the registry in a Win 2000 Server is to select the ___?

A. Emergency Repair Disk (ERD) B. Recovery Console

c. Last Known Good Configuration• Answer: C

• What routing protocol counts hops to the destination along multiple paths to determine the most efficient route?

A. ARP B. DLC C. RIP

• Answer: C • The source and destination addresses are stored in the

___ of a packet? A. data B. trailer C. header

• Answer: C • Most commonly used type of modem?

A. synchronous B. asynchronous C. external

• Answer: B • Operates at the network layer of the OSI model?

A. bridge B. gateway C. router

• Answer: C • Disk duplexing (RAID 1) requires a minimum of ___?

A. 2 hard drives and 1 controller B. 3 hard drives and 2 controllers C. 2 hard drives and 2 controllers

• Answer: C • Organization responsible for the OSI model?

A. ANSI B. IEEE C. ISO

• Answer: C • Which topology uses the least amount of cabling?

A. star B. bus C. ring

• Answer: B

Page 169: Question 1

• According to RFC 1918 this range of Class A IP addresses are reserved for private intranets and are not supposed to be used on the internet (where x is any number from 1 to 254)?

A. 10.x.x.x B. 20.x.x.x C. 30.x.x.x

• Answer: A • Cable classification for 10Base5 thicknet coaxial?

A. RG-8 B. RG-10 C. RG-58

• Answer: A • Dial-up protocol that uses a virtual private network (VPN)?

A. SLIP (Serial Line Internet Protocol) B. PPTP (Point-to-Point Tunneling Protocol) C. PPP (Point to Point Protocol)

• Answer: B • Type 9 ___ rated coaxial cable should be installed in drop ceilings to conform to fire code

regulations?

A. SPF B. PVC C. plenum

• AThe best device to use when monitoring a broadcast storm?

A. TDR B. Digital Voltmeter C. Protocol Analyzer

• Answer: C • Class A IP addresses can accomodate 16 million hosts while a Class B can accomodate

___?

A. 254 B. 65,534 C. 4 million

• Answer: B • SNMP relies on the information found in ___ to chart and graph components of the network

for analysis and troubleshooting?

A. SMPs B. MIBs C. SAPs

• Answer: B • Prescribes the greatest packet octet length that can be transmitted?

A. SAP B. subnet mask C. MTU

• Answer: C

• The default protocol on NT4 or Win 2000 servers?

A. IPX/SPX B. NWLink C. TCP/IP

• Answer: C • A standard security algorithm developed in 1975 that uses 56-bit symmetric key encryption?

A. DES B. EAP C. PAP

• Answer: A • Win 2000 security service that maintains permissions and passwords used to logon?

A. MMPE B. CHAP C. SAM

• Answer: C • A voice grade demand priority standard developed by HP that is capable of 100Mbps

transmissions?

A. 100VG-AnyLAN B. 100BaseT C. 100BaseFX

• Answer: A • PPP is part of the ___ OSI layer?

A. physical B. data link C. network

• Answer: B • Network connection device that is capable of sending packets along multiple paths depending on

which path is the most efficient?

A. bridge B. router C. all of the above

• Answer: B • Processes data using applications stored on its hard drive and sends the results back to the

client.Saving the client the extra hard drive space he would need for the application as well as the CPU processing time?

A. file server B. print server C. application server

• Answer: C • The static HOSTS text file used on UNIX systems that requires manual entries by the administrator

was the precursor of ___.Today the HOSTS file system finds use mainly in maximum security operations which don't want anything changed automatically?

A. WINS B. LMHOSTS C. DNS

• Answer: C

Page 170: Question 1

• The minimum category of UTP cable that will meet the 10BaseT standard?

A. cat2 B. cat3 C. cat5

• Answer: B • The easiest protocol to setup?

A. NetBEUI B. NWLink C. TCP/IP

• Answer: A • Displays data on hardware components such as memory, CPU, and the hard drive in a chart or

graph which describes how these devices are operating?

A. protocol analyzer B. performance monitor C. network monitor

• Answer: B • The OSI layer responsible for name recognition, security logins, and synchronization of the

connection?

A. presentation B. application C. session

• Answer: C • Has twenty-four 64 Kbps channels for a total of 1.544 Mbps throughput?

A. T3 B. T1 C. X.25

• Answer: B • Microsoft recommends that the %CPU usage should not be above 90% for a single CPU or

above __% for multiple processors for any extended period?

A. 50 B. 70 C. 90

• Answer: A • Your customer's computer is loaded with peripherals and is using COM1, COM2, LPT5, and

LPT7.You install the NIC on IRQ3 and have a conflict.Which of the following is the NIC conflicting with?

A. the printer B. COM1 C. COM2

• Answer: C • The most widely used protocol?

A. NetBEUI B. NWLink C. TCP/IP

• Answer: C

• Can be thought of as a "hop counter" determining how many hops it takes along various paths to the destination and then telling the router which is the one with the least number of hops which most of the time is the quickest route?

A. DLC B. SAP C. RIP

• Answer: C • Apple's LocalTalk protocol has a ___ computer limit?

A. 8 B. 32 C. 128

• Answer: B • Ensures that one device is NOT overwhelmed by another with a data transmission?

A. SMB B. CRC C. flow control

• Answer: C • You are setting up a 10Base2 Ethernet network for a client with three segments.There

are 20 computers in each segment.How many terminators will you need for this network?

A. 1 B. 2 C. 6

• Answer: C • Used to connect different media types but cannot filter or segment traffic?

A. bridge B. hub C. router

• Answer: B • The most efficient way to control security in a client/ server network is to assign

permissions to ___?

A. each shared resource B. directories C. groups

• Answer: C • Which of the following IRQs can you set your NIC to without usually causing a conflict?

A. 4 B. 7 C. 10

• Answer: C

Page 171: Question 1

• Characteristic of the TCP protocol?

A. fast but unreliable delivery B. best effort delivery C. assurance of packet delivery

• Answer: C • Cable type that offers the least resistance to EMI?

A. coaxial B. fiber-optic C. UTP

• Answer: C • Novell introduced TCP/IP as its default protocol in NetWare ___ ?

A. 3.x B. 4.x C. 5.x

• Answer: C • This OSI layer packages bits into frames?

A. physical B. data-link C. network

• Answer: B • Protocol used in Win 2000 to print to a URL on the internet.It requires either Peer Web

Services or a IIS server to be installed?

A. IPP B. SAP C. IPSec

• Answer: A • Novell added ___ which could bind many protocols to a NIC starting with NetWare 4.0?

A. NDIS B. TSM C. ODI

• Answer: C • Port ___ is assigned to the SMTP?

A. 21 B. 25 C. 80

• Answer: B • You are setting up a local peer-to-peer network that will have seven Win 98 computers.Internet

access is not needed.Which protocol should you use? • (NetBEUI is the best one but if its not listed then pick the one with the lowest overhead)

A. X.25 B. NWLink C. TCP/IP

• Answer: B • Used for installing Win NT4?

A. setup.exe B. winnt.exe C. win.com

• Answer: B

• OSI layer that determines whether the transmission is a full or half-duplex transfer?

A. presentation B. session C. application

• Answer: B • Compensates for a hard drive failure on an NT server?

A. RAID B. WINS C. DHCP

• Answer: A • In addition to DNS, DHCP, and Active Directory to boot from an RIS server in Win

2000 requires a ___ compliant NIC?

A. RAS B. PXE C. SAP

• Answer: B • The most popular dial-up protocol?

A. SLIP B. UDP C. PPP

• Answer: C • The standard for several hubs connected in a linear fashion (token-bus)?

A. 802.3 B. 802.4 C. 802.5

• Answer: B • The minimum number of disks required to implement a fault tolerant RAID

system?

A. 1 B. 2 C. 3

• Answer: B • For increased security Win 2000 enables encryption of files or folders on ___

volumes?

A. FAT32 B. NTFS C. either FAT32 or NTFS

• Answer: B

Page 172: Question 1

• OSI layer responsible for error checking frames and adding MAC addresses to its tables?

A. presentation B. transport C. data-link

• Answer: C • The initial formation of the packet header is started at this OSI level?

A. Application B. Session C. Physical

• Answer: A • For a Class C IP address the first ___ octet(s) are reserved for the

network ID?

A. 1 B. 2 C. 3

• Answer: C • Utility used to check SMTP connectivity?

A. SNMP B. LMHOSTS C. Telnet

• Answer: C • Prevents bounce-back of signals in a 10Base2 network?

A. T-connector B. BNC C. terminator

• Answer: C • A set of "rules" for network transmissions?

A. topologies B. protocols C. gateways

• Answer: B• What bridging protocol can be used to prevent bridge looping when

more than one physical path exists between two or more network segments?

A. The Spanning Tree Protocol B. The Inverted Tree Protocol C. The Transparent Tree Protocol D. The Domain Name Tree Protocol E. The Looping Bridge Protocol

• Answer: A

• What are the two methods switching hubs use to transport data between devices?

A. Routing B. Forwarding C. Cut-through D. Active E. Store-and-forward

• Answer: E,C • What happens when a device is disconnected from the middle of a BUS network?

A. The hub will propagate error messages to the rest of the network B. All devices on the network will fail C. The Server will stop responding to that device D. Data will not be able to get to devices on the other side of this

device E. If a bridge is on the network, only that segment will be effected

• Answer: A • What are some advantages of a Client/Server network over a Peer-to-Peer network?

A. Performance is better on a Peer-to-Peer B. Security is better on a Client/Server C. Performance is better on a Client/Server D. Security is better on a Peer-to-Peer E. Client/Server is easier to administrate

• Answer: E,B • Name two protocols in the TCP/IP suite that function at the Transport layer of the OSI

model.

A. TCP B. IP C. UDP D. SNMP E. ARP

• Answer: C,A • IP is responsible for sorting and _________________ of packets.

A. Addressing B. Holding C. Organizing D. Delivery E. Verifying

• Answer: D

Page 173: Question 1

• What is the first octet range for a class B IP address?

A. 127-191 B. 128-191 C. 192-223 D. 1-127 E. 128-255

• Answer: B • What is the first octet range for a class C IP address?

A. 1-126 B. 128-191 C. 192-225 D. 192-223 E. 192-255

• Answer: D • What method of transporting data with a switch is fastest?

A. Store-and-forward B. Cut-through C. Routing D. Spanning Tree E. Pass-Through

• Answer: B • The inner core of a coaxial cable that carries the signals is made of ___?

A. aluminum B. copper C. zinc

• Answer: B • Active hubs can ___?

A. route the signal using the most efficient path B. send an acknowledgement once the packet is received C. regenerate the signal like repeaters

• Answer: C • RAID 5 requires a minimum of __ hard drives?

A. 3 B. 4 C. 5

• Answer: A • What is an advantage of Cat 3 UTP cable instead of RG-58 A/U coaxial?

A. UTP supports longer cable segments B. UTP is less susceptible to EMI C. UTP is easier to install and less expensive

• Answer: C

• A packet in a TCP/IP network whose destination is outside the local network goes to the ___?

A. TCP transceiver B. default gateway C. IP subnet

• Answer: B • One important difference between routers and bridges is that when a

bridge can't locate the destination address in its table it ___?

A. sends the transmission to the default gateway B. dumps the packet C. broadcasts the transmission to all ports

• Answer: C • Novell's NetWare 5.0 was developed in part from the ___ standard?

A. ATM B. NDIS C. X.500

• Answer: C • The freely distributed open source Unix based operating system that has

gained in popularity recently?

A. XP B. Linux C. DLC

• Answer: B • The term used to describe the physical layout of a network?

A. protocol B. server C. topology

• Answer: C • Is the interface between the NIC drivers and MAC sublayer?

A. WINS B. NDIS C. DLC

• Answer: B

Page 174: Question 1

• Records the number of hops and latency of the packet on its way to its destination?

A. IPCONFIG B. TRACERT C. PING

• Answer: B • NDIS operates at which layer of the OSI model?

A. presentation B. data-link C. network

• Answer: B • When checking the TCP/IP protocol you have just

finished installing for connectivity the proper first step it to ___?

A. PING another computer on that segment B. PING 127.0.0.1 C. PING the default gateway

• Answer: B • As data travels down the OSI layers it reaches the ___

layer which is responsible for its bit conversion and actual transmission to other computers?

A. network B. application C. physical

• Answer: C • Can switching hubs propagate broadcast packets on the

network? A. Yes B. No

• Answer: A • How many physical addresses can be assigned to a

NIC? A. One B. Two C. Three; One by the IEEE, one by the NIC vendor, and one

by the Network Administrator D. Depends on the NOS E. Depends on the NIC driver

• Answer: A

• What are the two types of routing connections? A. Token passing B. Connectionless C. Reliable D. Connection Orientated E. Unreliable

• Answer: D,B • What type of routing connection would typically fragment

data packets? A. Connection Orientated B. Cut-Through C. Reliable D. Connectionless E. Static

• Answer: D • What name is given to Novell's client software loaded on the

workstation, and what feature does it provide that earlier versions of the Generic Windows client do not offer?

A. NETX B. Client for NetWare Networks C. Client32 D. Support for NetWare Print Queues E. Support for NetWare Directory Services

• Answer: C,E • If two computers are assigned the same IP address then ___?

A. neither computer will be able to connect B. the first computer to sign on will be able to connect the other will not C. both computers will be able to connect to the local network but not to the

internet • Answer: B • The physical address assigned by the NIC manufacturer?

A. subnet mask B. IP address C. MAC address

• Answer: C

Page 175: Question 1

• Similar to WINS in that it resolves NetBIOS names into IP address but stores this information in a text file?

A. LMHOSTS B. DLC C. DNS

• Answer: A • A small peer to peer network uses ___ security?

A. user-level B. share-level C. permissions for

• Answer: B • The TCP/IP protocol used on the internet allows for approximately ___ billion

unique IP addresses?

A. 1 B. 4 C. 10

• Answer: B • What happens when a device is disconnected from the middle of a BUS network?

A. The hub will propagate error messages to the rest of the network B. All devices on the network will fail C. The Server will stop responding to that device D. Data will not be able to get to devices on the other side of this

device E. If a bridge is on the network, only that segment will be effected

• Answer: B • Why is there a limit to the number of MAUs that can be connected together in a

standard Token-ring network?

A. Too many MAUs would exceed the cable limits imposed by the Token Ring specification

B. Too many MAUs would create to large of a collision domain for communications to take place

C. Too many MAUs require more electricity than the devices can support

D. Too many devices connected through MAUs requires more time to get control of the token that communications becomes unacceptable

E. There is no limit to the number of MAUs a token ring network can support

• Answer: D

• How many devices can communicate simultaneously within a Token-ring LAN?

A. One for each MAU on the LAN B. One C. Two D. As many devices as the administrator defines within the NOS E. Between 1 and 5 if the ring speed is 16mbp/s

• Answer: B • What are three common items that must be configured correctly when installing a Network Interface

Card (NIC)?

A. PCI or ISA slot B. IRQ setting C. DMA Address D. Driver E. I/O Address

• Answer: B,C,D,E • When troubleshooting connection problems you can confirm that physical layer devices are

communicating by visually inspecting _______________ on the NIC and hub.

A. Cross over cable B. The Link-Lights C. The electrical connection D. The Patch cable E. The power light

• Answer: B • What is the name of a common test performed on a NIC with vendor supplied diagnostic software?

A. NIC Test B. Diagnostic Test C. PING D. Loopback E. NICBack

• Answer: D • Name two driver interfaces that allow a NIC to communicate on more than one protocol.

A. NDIS B. NetBEUI C. NetBIOS D. ODI E. UNIX

• Answer: D,A • Bridges operate at the _____________ OSI level.

A. The Data-Link Layer B. Top Layer C. The Transport Layer D. The Session Layer E. The Network Layer

• Answer: A

Page 176: Question 1

• What bridging method is commonly used in Ethernet with only one bridge.

A. Collision B. Routing C. Transparent D. Spanning Tree E. Open Shortest Path First (OSPF)

• Answer: C • Where are bridging address tables maintained when using source-route bridging?

A. In routing tables on the hard drive B. In routing tables in RAM C. In routing tables in ROM D. At each PC on the network E. On special routing devices

• Answer: A • Characteristic of an IEEE 802.3 10BaseT Ethernet network?

A. BNC T-connectors B. RJ-11 C. UTP

• Answer: C • You suspect a faulty NIC is causing a broadcast storm in a network.What troubleshooting

tool would you use to locate which computer has the defective NIC?

A. VOM B. protocol analyzer C. TDR

• Answer: B • A dial-up protocol that does not support automatic IP addressing using DHCP?

A. PPP B. DLC C. SLIP

• Answer: C • Of the two types of routers the one that uses the discovery process to create its routing

table?

A. static B. dynamic C. multiplexed

• Answer: B • Your client's NT server has been having trouble booting.Where should you look first for

some answers?

A. performance monitor B. event viewer C. SNMP

• Answer: B

• Another fast non-routable protocol with low overhead developed by DEC?

A. ATM B. LAT C. SPX

• Answer: B • You are hired to setup a 100Mbps Ethernet network for a client in an

office that already has cat 3 UTP installed.Your client wants to keep the costs to a minimum but needs the 100Mbps throughput.What should you recommend?

A. keep the existing cable but purchase 100Mbps hubs B. keep the existing cable but use 100Mbps patch cable

from the wall outlet C. new cat 5 UTP and if not already installed 100 Mbps

hubs and 100 Mbps NICs • Answer: C • Your client's 10BaseT Ethernet network using NetBEUI wants to access

data on an IBM mainframe.What device will allow this connection?

A. bridge B. gateway C. router

• Answer: B • Of the following protocols which is the fastest?

A. TCP/IP B. IPX/SPX C. UDP/IP

• Answer: C • Access to files and folders in Win 2000 is accomplished using ___ ?

A. compression B. tunneling C. permissions

• Answer: C

Page 177: Question 1

• A ___ is used to connect two pieces of 10Base2 coaxial cable together?

A. T-connector B. barrel connector C. patch cable

• Answer: B • One reason the ATM WAN protocol is faster than Frame Relay is because its

packets are a ___ size which allows them to be switched and routed more easily?

A. variable B. fixed C. compressed

• Answer: B • SQL is used to ___?

A. access databases B. setup the default gateway C. identify a defective NIC

• Answer: A • Which of the following is a routable protocol?

A. LAT B. NWLink C. DLC

• Answer: B • Uses token passing?

A. Frame Relay B. ArcNet C. ATM

• Answer: B • For Cat 5 UTP, patch cables from the wall outlet to the computer can be a

maximum of ___ m?

A. 1 B. 3 C. 10

• Answer: B • The static text file ___ and DNS contain similar names and IP addresses?

A. LMHOSTS B. HOSTS C. WINS

• Answer: B

• Increases the data rate of modems?

A. encryption B. compression C. synchronization

• Answer: B • Wireless technology commonly used to connect workstations that are all located

in a single room?

A. IrDA B. microwave C. SONET

• Answer: A • Your customer has a client/ server Ethernet network consisting of a server and 225

computers running Win NT4.What kind of security would you recommend to him for centralized control of access to files and directories on the network?

A. use a password for each file and groups for each directory B. use a password for each file and directory shared C. setup groups of shared resources and users who have access

to these groups • Answer: C • Running performance monitor your CPU usage averages 45% except when you load

an application and it surges to 100%.Is there a problem?

A. yes, your CPU needs an upgrade or multiple CPUs may have to be installed

B. yes, but it is not the CPU, you need more RAM C. no, its normal for the %usage to surge when loading an

application • Answer: C • Interface between the computer and POTS?

A. ATAPI B. SONET C. TAPI

• Answer: C • The following protocols are supported by RAS?

A. TCP/IP B. NetBEUI C. all of the above

• Answer: C

Page 178: Question 1

• Which architecture is recommended under high network utilization of up to 70% or 80%?

A. Ethernet bus B. Token Ring C. DLC

• Answer: B • A token-ring network has a maximum limit of ___ computers?

A. 1024 B. 260 C. 512

• Answer: B • Dial-up protocol used when a secure connection is desired?

A. PPP B. SLIP C. PPTP

• Answer: C • Your IP address is 135.72.14.43.What portion of this IP address

identifies your network ID?

A. 135 B. 135.72 C. 135.72.14

• Answer: B • Allows users to connect to a remote network with a PPP dial-

up connection?

A. RAS B. SAP C. SONET

• Answer: A

• Which of the following protocols need to be installed on your client's NT system before DHCP and DNS can be enabled?

A. TCP/IP B. IPX/SPX C. NetBEUI

• Answer: A • A router uses ___ addressing to choose its path?

A. physical B. logical C. system

• Answer: B • Which topology provides for equal access to the network for all computers?

A. star B. bus C. ring

• Answer: C • Using the TCP/IP protocol when is a subnet mask required?

A. only when connecting outside the LAN B. only when using TCP/IP C. for both intranet and internet usage

• Answer: C • OSI level that ensures error-free delivery of packets?

A. data-link B. network C. transport

• Answer: C • The IEEE specification for a token ring network?

A. 802.3 B. 802.5 C. 802.6

• Answer: B • RIP counts hops (or routers it encounters) as the packet travels to its

destination.Another name for a hop is a ___?

A. interval B. sequence C. metric

• Answer: C

Page 179: Question 1

• A protocol that functions at the transport layer of the OSI model?

A. IP B. IPX C. SPX

• Answer: C • How many bits are there in an IP address?

A. 64 B. 32 C. 128

• Answer: B • An easy to configure, fast, and efficient protocol recommended for small non-

routable networks?

A. NetBEUI B. TCP/IP C. X.25

• Answer: A • What type of troubleshooting device examines the network at the packet level?

A. TDR B. VOM C. protocol analyzer

• Answer: C • Resolves domain names into IP addresses?

A. DHCP B. DNS C. WINIPCFG

• Answer: B • ___ uses data encryption to secure data being transmitted over the internet so even

if it is intercepted it can't be read without knowing the key?

A. DLC B. SSL C. ARP

• Answer: B • Device drivers can be disabled in Win 2000 Prof in Device Manager or by using the

___?

A. ERD B. Recovery Console C. RDISK

• Answer: B

• Smart Cards in Win 2000 use the ___ RAS authentication protocol for security?

A. PAP B. MSCHAP C. EAP

• Answer: C • Because of its low overhead this is the fastest of these protocols?

A. TCP/IP B. NWLink C. NetBEUI

• Answer: C • The ERD made in the Win 2000 Server Backup utility contains the files

needed to boot the computer?

A. True B. False

• Answer: B • Your client has a 10Base2 Ehternet network which is using 160m of RG-

58A/U cable and two 50 ohm terminators that are both grounded.What is wrong with his network?

A. the terminators should be 93 ohms B. he should be using RG-59/U cable C. only one terminator should be grounded

• Answer: C • Of the following the one that is NOT an alogorithm that determines the

shortest path for routers?

A. SAP B. RIP C. OSPF

• Answer: A • The most common topology in use today among corporate users?

A. bus B. ring C. star-bus

• Answer: C

Page 180: Question 1

Uses a 93 ohm resistor? A. RG62 B. RG58 C. RG59

Answer: A OSI level responsible for compression and encryption of data?

A. session B. application C. presentation

Answer: C

Page 181: Question 1

What is data structure? Answer: A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. List out the areas in which data structures are applied extensively? Answer: The name of areas are: Compiler Design, Operating System, Database Management System, Statistical analysis package, Numerical Analysis, Graphics, Artificial Intelligence, Simulation What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model. Answer: The major data structures used are as follows: RDBMS - Array (i.e. Array of structures) Network data model - Graph Hierarchical data model - Trees

Page 182: Question 1

Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and Postfix notations. Answer: Prefix Notation: ^ - * +ABC - DE + FG Postfix Notation: AB + C * DE - - FG + ^ How many null branches are there in a binary tree with 20 nodes? Answer: 21 Let us take a tree with 5 nodes (n=5)

It will have only 6 (ie,5+1) null branches.A binary tree with n nodes has exactly n+1 null nodes. What are the methods available in storing sequential files? Answer: The methods available in storing sequential files are:

Straight merging, Natural merging, Polyphase sort, Distribution of Initial runs.

Page 183: Question 1

If you are using C language to implement the heterogeneous linked list, what pointer type will you use? Answer: The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type. Minimum number of queues needed to implement the priority queue? Answer: Two. One queue is used for actual storing of data and another for storing priorities. What is the data structures used to perform recursion? Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used. What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms? Answer: Polish and Reverse Polish notations.

Page 184: Question 1

How many different trees are possible with 10 nodes ? Answer: 1014 For example, consider a tree with 3 nodes(n=3), it will have the maximum combination of 5 different (ie, 23 - 3 = 5) trees.

In general:If there are n nodes, there exist 2n-n different trees.

Page 185: Question 1

List out few of the Application of tree data-structure? Answer: The list is as follows: The manipulation of Arithmetic expression, Symbol Table construction, Syntax analysis.

List out few of the applications that make use of Multilinked Structures? Answer: The applications are listed below:

Sparse matrix, Index generation.

In tree construction which is the suitable efficient data structure? Answer: Linked list is the efficient data structure. What is the type of the algorithm used in solving the 8 Queens problem? Answer: Backtracking

Page 186: Question 1

In an AVL tree, at what condition the balancing is to be done? Answer: If the 'pivotal value' (or the 'Height factor') is greater than 1 or less than -1. What is the bucket size, when the overlapping and collision occur at same time? Answer: One. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values.

Traverse the given tree using Inorder, Preorder and Postorder traversals.

Traverse the given tree using Inorder, Preorder and Postorder traversals.

Answer: Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A

Page 187: Question 1

There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree? Answer: 15.In general:There are 2n-1 nodes in a full binary tree. By the method of elimination:Full binary trees contain odd number of nodes. So there cannot be full binary trees with 8 or 14 nodes, so rejected. With 13 nodes you can form a complete binary tree but not a full binary tree. So the correct answer is 15. In the given binary tree, using array you can store the node 4 at which location?

Answer: At location 6

1

2 3 - - 4 - - 5

Root LC1 RC1 LC2 RC2 LC3 RC3 LC4 RC4

where LCn means Left Child of node n and RCn means Right Child of node n

Page 188: Question 1

For the given graph, draw the DFS and BFS

Answer: BFS: A X G H P E M Y J DFS: A X H P E Y M J G

Classify the Hashing Functions based on the various methods by which the key value is found. Answer: The list of Hashing functions is as follows:

Direct method Subtraction method Modulo-Division method Digit-Extraction method Mid-Square method Folding method Pseudo-random method

Page 189: Question 1

What are the types of Collision Resolution Techniques and the methods used in each of the type? Answer: The types of Collision Resolution Techniques are:

Open addressing (closed hashing)The methods used include:Overflow block Closed addressing (open hashing)The methods used include:Linked list Binary tree

In RDBMS, what is the efficient data structure used in the internal storage representation? Answer: B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes. Draw the B-tree of order 3 created by inserting the following data arriving in sequence - 92 24 6 7 11 8 22 4 5 16 19 20 78 Answer:

Page 190: Question 1

What is a spanning Tree? Answer: A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes? Answer: No. Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

Convert the given graph with weighted edges to minimal spanning tree.

Answer: the equivalent minimal spanning tree is:

Page 191: Question 1

Whether Linked List is linear or Non-linear data structure? Answer: According to Access strategies Linked list is a linear one.According to Storage Linked List is a Non-linear one. Draw a binary Tree for the expression : A * B - (C + D) * (P / Q) Answer:

Page 192: Question 1

For the following COBOL code, draw the Binary tree? 01 STUDENT_REC.02 NAME.03 FIRST_NAME PIC X(10).03 LAST_NAME PIC X(10). 02 YEAR_OF_STUDY.03 FIRST_SEM PIC XX.03 SECOND_SEM PIC XX

Page 193: Question 1

•Explain the concept of Reentrancy. Answer: It is a useful, memory-saving technique for multiprogrammed timesharing systems. A Reentrant Procedure is one in which multiple users can share a single copy of a program during the same period. Reentrancy has 2 key aspects: The program code cannot modify itself, and the local data for each user process must be stored separately. Thus, the permanent part is the code, and the temporary part is the pointer back to the calling program and local variables used by that program. Each execution instance is called activation. It executes the code in the permanent part, but has its own copy of local variables/parameters. The temporary part associated with each activation is the activation record. Generally, the activation record is kept on the stack. Note: A reentrant procedure can be interrupted and called by an interrupting program, and still execute correctly on returning to the procedure.

•Explain Belady's Anomaly. Answer: Also called FIFO anomaly. Usually, on increasing the number of frames allocated to a process' virtual memory, the process execution is faster, because fewer page faults occur. Sometimes, the reverse happens, i.e., the execution time increases even when more frames are allocated to the process. This is Belady's Anomaly. This is true for certain page reference patterns.

Page 194: Question 1

•What is a binary semaphore? What is its use? Answer: A binary semaphore is one, which takes only 0 and 1 as values. They are used to implement mutual exclusion and synchronize concurrent processes. •What is thrashing? Answer: It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults.

•List the Coffman's conditions that lead to a deadlock. Answer: •Mutual Exclusion: Only one process may use a critical resource at a time. •Hold & Wait: A process may be allocated some resources while waiting for others. •No Pre-emption: No resource can be forcible removed from a process holding it. •Circular Wait: A closed chain of processes exist such that each process holds at least one resource needed by another process in the chain.

Page 195: Question 1

•What are short-, long- and medium-term scheduling? Answer: Long term scheduler determines which programs are admitted to the system for processing. It controls the degree of multiprogramming. Once admitted, a job becomes a process. Medium term scheduling is part of the swapping function. This relates to processes that are in a blocked or suspended state. They are swapped out of real-memory until they are ready to execute. The swapping-in decision is based on memory-management criteria. Short term scheduler, also know as a dispatcher executes most frequently, and makes the finest-grained decision of which process should execute next. This scheduler is invoked whenever an event occurs. It may lead to interruption of one process by preemption.•What are turnaround time and response time? Answer: Turnaround time is the interval between the submission of a job and its completion. Response time is the interval between submission of a request, and the first response to that request. •What are the typical elements of a process image? Answer: •User data: Modifiable part of user space. May include program data, user stack area, and •programs that may be modified. •User program: The instructions to be executed. •System Stack: Each process has one or more LIFO stacks associated with it. Used to store •parameters and calling addresses for procedure and system calls. •Process control Block (PCB): Info needed by the OS to control processes

Page 196: Question 1

•What is cycle stealing? Answer: We encounter cycle stealing in the context of Direct Memory Access (DMA). Either the DMA controller can use the data bus when the CPU does not need it, or it may force the CPU to temporarily suspend operation. The latter technique is called cycle stealing. Note that cycle stealing can be done only at specific break points in an instruction cycle. •What is meant by arm-stickiness? Answer: If one or a few processes have a high access rate to data on one track of a storage disk, then they may monopolize the device by repeated requests to that track. This generally happens with most common device scheduling algorithms (LIFO, SSTF, C-SCAN, etc). High-density multisurface disks are more likely to be affected by this than low density ones.

Page 197: Question 1

•What are the stipulations of C2 level security? Answer: C2 level security provides for: •Discretionary Access Control •Identification and Authentication •Auditing •Resource reuse•What is busy waiting? Answer: The repeated execution of a loop of code while waiting for an event to occur is called busy-waiting. The CPU is not engaged in any real productive activity during this period, and the process does not progress toward completion. •Explain the popular multiprocessor thread-scheduling strategies. Answer: •Load Sharing: Processes are not assigned to a particular processor. A global queue of threads is maintained. Each processor, when idle, selects a thread from this queue. Note that load balancing refers to a scheme where work is allocated to processors on a more permanent basis. •Gang Scheduling: A set of related threads is scheduled to run on a set of processors at the same time, on a 1-to-1 basis. Closely related threads / processes may be scheduled this way to reduce synchronization blocking, and minimize process switching. Group scheduling predated this strategy. •Dedicated processor assignment: Provides implicit scheduling defined by assignment of threads to processors. For the duration of program execution, each program is allocated a set of processors equal in number to the number of threads in the program. Processors are chosen from the available pool. •Dynamic scheduling: The number of thread in a program can be altered during the course of execution.

Page 198: Question 1

•When does the condition 'rendezvous' arise? Answer: In message passing, it is the condition in which, both, the sender and receiver are blocked until the message is delivered. •What is a trap and trapdoor? Answer: Trapdoor is a secret undocumented entry point into a program used to grant access without normal methods of access authentication. A trap is a software interrupt, usually the result of an error condition. •What are local and global page replacements? Answer: Local replacement means that an incoming page is brought in only to the relevant process' address space. Global replacement policy allows any page frame from any process to be replaced. The latter is applicable to variable partitions model only. •Define latency, transfer and seek time with respect to disk I/O. Answer: Seek time is the time required to move the disk arm to the required track. Rotational delay or latency is the time it takes for the beginning of the required sector to reach the head. Sum of seek time (if any) and latency is the access time. Time taken to actually transfer a span of data is transfer time.

Page 199: Question 1

•Describe the Buddy system of memory allocation. Answer: Free memory is maintained in linked lists, each of equal sized blocks. Any such block is of size 2^k. When some memory is required by a process, the block size of next higher order is chosen, and broken into two. Note that the two such pieces differ in address only in their kth bit. Such pieces are called buddies. When any used block is freed, the OS checks to see if its buddy is also free. If so, it is rejoined, and put into the original free-block linked-list.

What is time-stamping? Answer: It is a technique proposed by Lamport, used to order events in a distributed system without the use of clocks. This scheme is intended to order events consisting of the transmission of messages. Each system 'i' in the network maintains a counter Ci. Every time a system transmits a message, it increments its counter by 1 and attaches the time-stamp Ti to the message. When a message is received, the receiving system 'j' sets its counter Cj to 1 more than the maximum of its current value and the incoming time-stamp Ti. At each site, the ordering of messages is determined by the following rules: For messages x from site i and y from site j, x precedes y if one of the following conditions holds....(a) if Ti<j.< and Ti="Tj" if (b) or> •How are the wait/signal operations for monitor different from those for semaphores? Answer: If a process in a monitor signal and no task is waiting on the condition variable, the signal is lost. So this allows easier program design. Whereas in semaphores, every operation affects the value of the semaphore, so the wait and signal operations should be perfectly balanced in the program.

Page 200: Question 1

•In the context of memory management, what are placement and replacement algorithms? Answer: Placement algorithms determine where in available real-memory to load a program. Common methods are first-fit, next-fit, best-fit. Replacement algorithms are used when memory is full, and one process (or part of a process) needs to be swapped out to accommodate a new program. The replacement algorithm determines which are the partitions to be swapped out. •In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking? Answer: For load-time dynamic linking: Load module to be loaded is read into memory. Any reference to a target external module causes that module to be loaded and the references are updated to a relative address from the start base address of the application module. With run-time dynamic loading: Some of the linking is postponed until actual reference during execution. Then the correct module is loaded and linked. •What are demand- and pre-paging? Answer: With demand paging, a page is brought into memory only when a location on that page is actually referenced during execution. With pre-paging, pages other than the one demanded by a page fault are brought in. The selection of such pages is done based on common access patterns, especially for secondary memory devices. •Paging a memory management function, while multiprogramming a processor management function, are the two interdependent? Answer: Yes. •What is page cannibalizing? Answer: Page swapping or page replacements are called page cannibalizing. •What has triggered the need for multitasking in PCs? Answer: Increased speed and memory capacity of microprocessors together with the support fir virtual memory and Growth of client server computing •What are the four layers that Windows NT have in order to achieve independence? Answer: •Hardware abstraction layer •Kernel •Subsystems •System Services.

Page 201: Question 1

•What is SMP? Answer: To achieve maximum efficiency and reliability a mode of operation known as symmetric multiprocessing is used. In essence, with SMP any process or threads can be assigned to any processor. •What are the key object oriented concepts used by Windows NT? Answer: Encapsulation Object class and instance •Is Windows NT a full blown object oriented operating system? Give reasons. Answer: No Windows NT is not so, because its not implemented in object oriented language and the data structures reside within one executive component and are not represented as objects and it does not support object oriented capabilities .

Page 202: Question 1

•What is the Translation Lookaside Buffer (TLB)? Answer: In a cached system, the base addresses of the last few referenced pages is maintained in registers called the TLB that aids in faster lookup. TLB contains those page-table entries that have been most recently used. Normally, each virtual memory reference causes 2 physical memory accesses-- one to fetch appropriate page-table entry, and one to fetch the desired data. Using TLB in-between, this is reduced to just one physical memory access in cases of TLB-hit. •What is the resident set and working set of a process? Answer: Resident set is that portion of the process image that is actually in real-memory at a particular instant. Working set is that subset of resident set that is actually needed for execution. (Relate this to the variable-window size method for swapping techniques.)

Page 203: Question 1

•What is an idle thread? Answer: The special thread a dispatcher will execute when no ready thread is found. •What is FtDisk? Answer: It is a fault tolerance disk driver for Windows NT. •What are the possible threads a thread can have? Answer: •Ready •Standby •Running •Waiting •Transition •Terminated.•What are rings in Windows NT? Answer: Windows NT uses protection mechanism called rings provides by the process to implement separation between the user mode and kernel mode. •What is Executive in Windows NT? Answer: In Windows NT, executive refers to the operating system code that runs in kernel mode. •What are the sub-components of I/O manager in Windows NT?

Page 204: Question 1

•Answer: •Network redirector/ Server •Cache manager. •File systems •Network driver •Device driver•What are DDks? Name an operating system that includes this feature. Answer: DDks are device driver kits, which are equivalent to SDKs for writing device drivers. Windows NT includes DDks. •What level of security does Windows NT meets? Answer: C2 level security.

Questions on file management in uinxFollowing are some unix sample questions. How are devices represented in UNIX?

All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way. A 'regular file' is just an ordinary data file in the disk. A 'block special file' represents a device with characteristics similar to a disk (data transfer in terms of blocks). A 'character special file' represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order).

Page 205: Question 1

•What is 'inode'? Answer: All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to additional data blocks (this further aggregates for larger files). A block is typically 8k. Inode consists of the following fields: •File owner identifier •File type •File access permissions •File access times •Number of links •File size •Location of the file data•Brief about the directory representation in UNIX Answer: A Unix directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are created, kernel makes two entries named '.' (refers to the directory itself) and '..' (refers to parent directory). System call for creating directory is mkdir (pathname, mode).

Page 206: Question 1

•What are the Unix system calls for I/O? Answer: •open(pathname,flag,mode) - open file •creat(pathname,mode) - create file •close(filedes) - close an open file •read(filedes,buffer,bytes) - read data from an open file •write(filedes,buffer,bytes) - write data to an open file •lseek(filedes,offset,from) - position an open file •dup(filedes) - duplicate an existing file descriptor •dup2(oldfd,newfd) - duplicate to a desired file descriptor •fcntl(filedes,cmd,arg) - change properties of an open file •ioctl(filedes,request,arg) - change the behaviour of an open fileThe difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations. •How do you change File Access Permissions? Answer: Every file has following attributes: •owner's user ID ( 16 bit integer ) •owner's group ID ( 16 bit integer ) •File access mode word 'r w x -r w x- r w x' (user permission-group permission-others permission) r-read, w-write, x-execute

To change the access mode, we use chmod(filename,mode). Example 1: To change mode of myfile to 'rw-rw-r--' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as: chmod(myfile,0664) . Each operation is represented by discrete values 'r' is 4 'w' is 2 'x' is 1 Therefore, for 'rw' the value is 6(4+2). Example 2: To change mode of myfile to 'rwxr--r--' we give the args as: chmod(myfile,0744).

Page 207: Question 1

•What are links and symbolic links in UNIX file system? Answer: A link is a second name (not a file) for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers. Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links. Commands for linking files are: Link ln filename1 filename2 Symbolic link ln -s filename1 filename2

Page 208: Question 1

What is a FIFO? Answer: FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in interprocess communication where a process writes to one end of the pipe (producer) and the other reads from the other end (consumer). •How do you create special files like named pipes and device files? Answer: The system call mknod creates special files in the following sequence. 1.kernel assigns new inode, 2.sets the file type to indicate that the file is a pipe, directory or special file, 3.If it is a device file, it makes the other entries like major, minor device numbers.For example: If the device is a disk, major device number refers to the disk controller and minor device number is the disk.•Discuss the mount and unmount system calls Answer: The privileged mount system call is used to attach a file system to a directory of another file system; the unmount system call detaches a file system. When you mount another file system on to your directory, you are essentially splicing one directory tree onto a branch in another directory tree. The first argument to mount call is the mount point, that is , a directory in the current file naming system. The second argument is the file system to mount to that point. When you insert a cdrom to your unix system's drive, the file system in the cdrom automatically mounts to /dev/cdrom in your system. •How does the inode map to data block of a file? Answer: Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks in the file. The 11th address points to a one-level index block. The 12th address points to a two-level (double in-direction) index block. The 13th address points to a three-level(triple in-direction)index block. This provides a very large maximum file size with efficient access to large files, but also small files are accessed directly in one disk read. •What is a shell? Answer: A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS are presented to the user through an interactive interface. Commonly used shells are sh,csh,ks etc.

Page 209: Question 1

•Brief about the initial process sequence while the system boots up. Answer: While booting, special process called the 'swapper' or 'scheduler' is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children: the process dispatcher, vhand and dbflush with IDs 1,2 and 3 respectively. This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. Unix keeps track of all the processes in an internal data structure called the Process Table (listing command is ps -el).•What are various IDs associated with a process? Answer: Unix identifies each process with a unique integer called ProcessID. The process that executes the request for creation of a process is called the 'parent process' whose PID is 'Parent Process ID'. Every process is associated with a particular user called the 'owner' who has privileges over the process. The identification for the user is 'UserID'. Owner is the user who executes the process. Process also has 'Effective User ID' which determines the access privileges for accessing resources like files. getpid() -process id getppid() -parent process id getuid() -user id geteuid() -effective user id •Explain fork() system call. Answer: The 'fork()' used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. We can tell which is which by checking the return value from 'fork()'. The parent gets the child's pid returned to him, but the child gets 0 returned to him. •Predict the output of the following program code main() { fork(); printf("Hello World!"); } Answer: Hello World!Hello World! Explanation: The fork creates a child that is a duplicate of the parent process. The child begins from the fork().All the statements after the call to fork() will be executed twice.(once by the parent process and other by child). The statement before fork() is executed only by the parent process. •Predict the output of the following program code main() { fork(); fork(); fork(); printf("Hello World!"); } Answer: "Hello World" will be printed 8 times. Explanation: 2^n times where n is the number of calls to fork()

Page 210: Question 1
Page 211: Question 1

•What is a drawback of MVT? Answer: It does not have the features like •ability to support multiple processors •virtual storage •source level debugging•What is process spawning? Answer: When the OS at the explicit request of another process creates a process, this action is called process spawning. •How many jobs can be run concurrently on MVT? Answer: 15 jobs •List out some reasons for process termination. Answer: •Normal completion •Time limit exceeded •Memory unavailable •Bounds violation •Protection error •Arithmetic error •Time overrun •I/O failure •Invalid instruction •Privileged instruction •Data misuse •Operator or OS intervention •Parent termination.•What are the reasons for process suspension? Answer: swapping •interactive user request •timing •parent process request•What is process migration? Answer: It is the transfer of sufficient amount of the state of process from one machine to the target machine •What is mutant? Answer: In Windows NT a mutant provides kernel mode or user mode mutual exclusion with the notion of ownership.

Page 212: Question 1

What is Software Engineering?

• Software engineering can be described in terms of analysis (front end software engineering; breaking apart a problem into pieces) and synthesis (back end software engineering; constructing a solution from available or new components). By analogy to other engineering disciplines, we can infer that software engineering attempts to establish the kinds of methods and tools that enable software projects to be built predictably within proscribed schedules and budgets, meeting the customer's requirements of functionality and reliability. Lethbridge's definition is: software engineering is the process of solving customers' problems by the systematic development and evolution of large-high quality software systems within cost, time, and other constraints.

• But software engineering is radically different than other engineering disciplines, in that:

• the end product is abstract, not a concrete object like a bridge

• costs are almost all human; materials are an ever shrinking fraction

• easy to fix bugs, but hard to test and validate

• software never wears out...but the hardware/os platforms it runs on do

• variations in application domain are open-ended, may require extensive new non-software, non-engineering knowledge for each project

Page 213: Question 1

Phases of Software Development Whether you follow the "Waterfall Model" or the "Spiral Model", software development includes the following aspects. The Waterfall Model says to do these things in order. The Spiral Model says to repeat these tasks in a cycle, adding detail and making corrections, until you know what you are doing. Note that many or most of these tasks produce documents, not programs, as their end result. Requirements Analysis Software Design Coding Testing Maintenance

Page 214: Question 1

Use Cases and Class Extraction You can identify classes from a software specification document by looking for

"interesting" nouns, where interesting implies there are some pieces of information to represent in your application, and operations to perform on them. You can also identify classes by developing use cases from the specification document. Use cases are formatted descriptions of "discrete" tasks. By "discrete", we mean an individual standalone thing a user does while using the system.

If you look through the tasks mentioned in a specification document, you can identify a set of candidates. Example candidate tasks for a "wargame":

• Combat • Roll dice • Move pieces • Perform the Missions Phase Example candidate tasks for Monopoly: 1. Buy property 2. Roll dice 3. Move piece 4. Count money

Page 215: Question 1

Terminology actor

role that an external entity plays in a system use case (or just "case")

depiction of some aspect of system functionality that is visible to one or more actors.

extension a use case that illustrates a different or deeper perspective on another use case

use a use cases that re-uses another use case.

We have previously introduced use cases and use case diagrams. Lethbridge defines a use case as: A use case is a typical sequence of actions that an actor performs in order to complete a given task. Now we will expand on the discussion of use cases, use case diagrams, and look at examples.

Page 216: Question 1

Use Case Descriptions Drawing an oval and putting the name of a task in it is not very helpful by itself, for each use case you need to add a detailed use case description. Your first homework assignment is to "go and do this" for your semester project. . Each use case has many or all of the following pieces of information. The items in bold would be found in any reasonable use case description. Name

The name of the use case. Actors

What participants are involved in this task. Goals

What those people are trying to accomplish. Preconditions

The initial state or event that triggers this task. Summary

Short paragraph stating what this task is all about. Related use cases

What use cases does this use case use or extend? What uses/extends this use case?

Page 217: Question 1

Steps The most common sequence of actions that are performed for this task. Lethbridge divides actions into two columns: user input is given in the left column, while system response is given in the right column. The two column format is optional, but saves on paper and may improve clarity. The steps are numbered, so there is no ambiguity in using both columns on each line.

Alternatives Some use cases may vary the normal sequence of steps.

Postconditions what does this task produce?

A simple generic use case for a "file open" operation might look like:

Open File Summary: A user performs this task in order to view a document. The user specifies a

filename and the document is opened in a new window. Steps:

1. Choose "Open" from the menu bar. 2. System displays a File Open dialog. 3. User selects a filename and clicks "OK". 4. System closes the dialog and opens the file in a new window. Alternative: If the user clicks Cancel in step 3, no file is opened

Page 218: Question 1

Exit parking lot, paying cash Actor: car driver Goal: to leave the parking lot Precondition: driver previously entered the parking lot, picked up a ticket, and has stayed in the lot long enough that they must pay to leave. Summary: driver brings their vehicle to an exit lane, inserts their ticket into a machine, and pays the amount shown on the machine. Related use case: exit parking lot, paying via credit card. Steps:

1. Drive to exit lane, triggering a sensor.

2. System prompts driver to insert their ticket.

3. Insert ticket. 4. System displays amount due.

5. Insert money into slot until cash in exceeds amount due.  

6. System returns change (if any) and raises exit barrier

7. Drive through exit, triggering a sensor.

8. Lower exit barrier

Page 219: Question 1

This one is for a library management application

Check out item for a borrower Actor: Checkout clerk (regularly), chief librarian (occasionally) Goal: Help the borrower borrow the item, and record the loan Precondition: The borrower wants to borrow a book, and must have a library card and not owe any fines. The item must be allowed for checkout (not on reserve, not from reference section, not a new periodical, etc.) Steps:

1. Scan item's bar code and borrower's library card.

2. Display confirmation that the loan is allowed, give due date.

3. Stamp item with the due date.

4. Click "OK" to check out item to borrower.

5. Record the loan and display confirmation that record has been made.

Alternative: the loan may be denied for any number of interesting reasons in step 2 (see preconditions).

Page 220: Question 1

Use Case Diagrams and Examples One reason to do a use case diagram is simply to summarize or catalog what tasks are part of the system; a sort of table of contents. But the main reason use case diagrams exist is in order to show who does what, when different users (actors) participate in different (overlapping) tasks. If you only have one actor, or there are no tasks in which multiple actors interact, there may be no reason that you have to do a use case dialog.

Page 221: Question 1

There are three actors (Registrar, Student, Professor), and there are five use cases. The "Find information about course" use case is vague and probably the three actor types can find out different information from each other. They are not typically involved in the same instance of finding out information about a class, so the example could be better.

a bunch of more exotic use case diagram items, namely actors and use cases that use or extend other actors and use cases.

Page 222: Question 1

Class Diagrams Class diagrams are the "meat and potatoes" of object-oriented analysis and design. We will begin our discussion of them today, and continue next week. Class diagrams describe more detailed, more implementation-oriented things than use case diagrams. Class diagrams can present varying levels of detail about the classes in them. Some class diagrams may have nothing more than the class name for each class; others may hold the full list of fields and methods. When more space is taken by class details, there is room for fewer classes per diagram, so you often have "overview diagrams" that show many classes and their connections, supplemented by "detail diagrams" that show more information about closely related classes.

Associations Perhaps the main purpose for class diagrams is to identify and depict relationships between objects that will be needed in the running system. An association is the word we use for such a relationship. We draw a line between the rectangles for classes to depict an assocation. There are three major types of associations:

inheritance aggregation user defined

Page 223: Question 1

Inheritance: the Un-Association We have discussed how inheritance is not really an association, it is a relationship between kinds of things, in the design and maybe in the programming language type system, whereas associations are relationships between instances (objects) at run-time. Inheritance is so vital that many class diagrams focus specifically on a large inheritance class hierarchy, similar to a biological taxonomy of species. Inheritance is usually a static feature of a design, although there exist languages in which instances can change who they inherit from at runtime.

Here is an example class hierarchy

Page 224: Question 1

Aggregation: the Simplest Association Aggregation, the parts-whole relationship, is perhaps the most useful association of all of them. Many many complex things are made up of an assembly of simpler items. There are at least two flavors of aggregation, static and dynamic. Static aggregation is lifelong aggregation; the parts cannot exist apart from the whole, or enter or leave the whole. Dynamic aggregation is more like a team whose members can come and go. Here is an example of a massive chain of aggregations with a familiar theme:

Page 225: Question 1

Association Details There are many details added to associations to show more information about the relationship. Some of these details are discussed in Chapter 5 in your text. link

just as classes have instances at runtime called objects, associations have instances at runtime called links. Links occasionally are so important and complicated that they need their own attributes. The main information about them is usually their lifetime, and what instances they are connecting.

multiplicity a.k.a. cardinality, it is the number of object instances per link instance in a given relationship

qualifier some many-to-one relationships have a unique key used to traverse the association.

roles the different ends of an association may have differing roles associated with them. Especially useful if both ends of an association connect the same class.

composition there is a special kind of aggregation called composition, which denotes aggregations in which the component parts have no existence apart from the whole thing. The relationship is hardwired, static, or constant. Composition is marked using a filled diamond; hollow diamond means a regular (transitory, or dynamic) aggregation.

Page 226: Question 1

Here are some more class diagram figures from some old software engineering text (Pfleeger). One point here is that it is logical to start with a simple sketch of classes and basic relationships, and add many details later on.

Page 227: Question 1
Page 228: Question 1
Page 229: Question 1

Statecharts A statechart, or state diagram, depicts dynamic properties of a system. See p. 276 of the text. A statechart consists of

a set of states drawn as circles, ovals, or rectangles, with a label or number inside.

a set of transitions drawn as arrows from one state to another.

a start state, and a set of final states Some of you may be getting an eery sense of deja vu at this point. Statecharts are a non-trivial extension of finite automata, because they have: instead of "input symbols", events associated with transitions

these may be complex, synchronous or asynchronous events may have conditions, drawn inside square brackets activities

Page 230: Question 1

Statechart Diagram Examples

Page 231: Question 1
Page 232: Question 1
Page 233: Question 1
Page 234: Question 1
Page 235: Question 1

Collaboration DiagramsCollaboration diagrams are the next form of UML diagram we will describe in this course. Collaboration diagrams describe how a set of objects interacts by calling from method to method. Collaboration Diagram Examples

Page 236: Question 1

A collaboration where an actor pushes a button to get an elevator to his floor. The control object checks how long the job queues of all the elevators are and chooses the shortest. It then creates a job order object and invokes it by putting it in a queue. The elevator object runs concurrently and picks up jobs from the queues. The elevator is an active object, meaning that it executes concurrently with its own thread of control.

Page 237: Question 1

The object MainWindow receives the message NewCustomer, and creates a Customer object. A CustomerWindow is created, and the customer object is then passed to the CustomerWindow which allows for update of the customer data.

Page 238: Question 1

Object Oriented Design: Adding Detail

Detailed Design You are dividing labor right now for work on phase 2, adding details and corrections to your project analysis, and merging ideas you find in other teams' homework #2. Make sure your names are on any submitted course documents. In fact, I need to know who did which parts of which documents, so I don't lump everyone together under the same grade. If you are asked to prepare part of a document you don't understand, better ask your classmates and/or instructor what is needed for that part.

Page 239: Question 1

User Interface Design By the next round of turnin, we will need to establish a fairly complete user interface design for things like the main screen. User Interface Design is the subject of an entire course (CS 485) and for our purposes we will have to settle for a rudimentary and primitive introduction. User interface design starts from what tasks/activities the application is to support. You probably will discover a few tasks in this phase that requires a dialog for a task we haven't identified previously. But mainly we need to design dialogs and sequences of actions to perform specific tasks in use cases.

Aspects of User Interfaces look

this is the most obvious part of user interface design, but not the most important part feel

this is like: what clicks perform what operations. how many clicks does it take. does it feel like you are directly manipulating the objects on the screen, or does it feel like you are following a long sequence of orders you receive from the program.

metaphors users can quickly learn an unfamiliar task, or quickly interpret an unfamiliar graphic, if a familiar metaphor is used. Examples: "desktop metaphor"

mental model a user interface provides the user with a particular mental model of how they view the system. designing that model will determine many aspects of the user interface (what info to show, what tasks to support)

navigation rules navigation through large structures which don't all fit on the screen is a central issue for many (most) applications.

Page 240: Question 1

A few Obvious User Interface Tips 1. Minimize # of clicks for common tasks 2. Provide all the information that's needed on a single screen 3. Strive for "direct manipulation" 4. Modeless is usually better than modal 5. Be familiar and consistent with other applications

Interpersonal Communications: Some Rules of Engagement 1. Respect your classmates, even when you disagree or they are wrong.

"Treat others the way you would like to be treated" - Jesus. I am not impressed, and will not tolerate for long, group "leaders" who disrespect their teammates publically. If you have a problem with one of your team member's contributions, discuss it with them privately. If you cannot resolve it through polite discussion with the individual, discuss it RESPECTFULLY within your group, and if there is a problem that can't be resolved internally, see me. Part of your grade will be based on whether I determine that you respected your classmates or not.

2. Accept group decisions even when you disagree. "The Needs of the Many Outweigh the Needs of the Few...or the One" - Spock. There has to be some

mechanism for making decisions, whether it is democracy, dictatorship, or whatever. Those decisions should be made based on what's best for the group, not what makes an individual look good.

3. You must include all group members in decisions. I want to hear no more team members who are surprised about something that affects them.

4. You should do your best to contribute to your team. "From each according to his abilities" - Marx. The easiest way to fail this course is to not contribute to your

team. If you do your best, make your contribution, and the team discards it, that is not your problem or fault. If you don't do your best to help your team succeed, don't be surprised at the grade you get.

5. E-mail is not a good medium for resolving problems. I have found through many long years that e-mail does not work well at conveying emotions. Using e-mail

to try to resolve problems can easily make them worse. Of course, sometimes you have no choice, but basically e-mail is easily misinterpreted. Human faces and intonation are lost, and people do not type as well as they talk. When there is a problem, your best bet is to e-mail to setup a meeting to discuss it. Your next best bet is to think, and rethink, what you are planning to send by e-mail. Ask: how will this person react to this e-mail? Have I respected them? Will they understand my situation? Will they feel I am attacking them, or trying to help?

Page 241: Question 1

Design methods 1. modular decomposition

top-down breaking up function into parts 2. data-oriented decomposition

top-down breaking up information into parts 3. event-oriented decomposition

identifying what changes are to be made, and when they occur 4. outside-in design

blackbox I/O orientation 5. object-oriented design

relationships between data

Things that get designed 1. Architecture

interaction between programs and their environment, including other programs 2. Code

algorithms and data structures, starting with equations, pseudocode, etc. 3. Executable/package

how is this system going to be installed and run on user machines? Common architectures Pipes, layers, client-server, peer-to-peer, ring ... Some common breakdowns 1. poor prioritization 2. failure to consider constraints on the solution (missing requirements) 3. failing to perform mental simulations of complex multi-step activities 4. failing to track and return to subproblems which aren't solved yet 5. failing to expand/merge/integrate subsolutions into a complete whole

Page 242: Question 1

"Good" Design. Low coupling

Coupling refers to the interdependences between components. Components need to be as independent as possible. The book defines many kinds of coupling, including content coupling, control coupling, stamp coupling, and data coupling.

High cohesion Cohesion refers to the degree to which a component is focused and connected internally (it is almost "internal coupling"). Bad cohesion has a single component doing unrelated tasks. Bad cohesion may coinside with lots of duplicate code (same thing repeated with slight changes for different tasks). The book defines levels of cohesion: coincidental, logical, temporal, procedural, communicational, sequential, functional.

Minimal complexity There are several types of complexity, but in general, complexity is bad, and the goal is to minimize it while meeting requirements. Most of the complexity measures that are out there measure the complexity of code, but we are talking about design right now. Designs that are complex, or designs that poorly address the application domain and requirements, lead to complex code. Bad programmers can of course create complex code from even good designs.

Page 243: Question 1

Final Exam Review The final exam will cover the whole course, with an emphasis on software engineering "back-end" issues. Review your UML, especially parts you missed on the midterm -- what is the difference between a state and an event? When I ask you to draw a statechart, knowing what a state is will be important. What is the difference between a class and an association? There were in general more misunderstandings about statecharts than about class diagrams, and more misunderstandings about collaboration diagrams than about statecharts. What is the purpose of a collaboration diagram? What tasks are involved in the so-called ``back end'' of software development? When you take a UML class diagram and write the code that corresponds to it, how to you implement each of the things you see in the diagram? The closer the language corresponds back to the diagramming notation, the easier it will be to implement from a design and keep them in sync. What is software testing? What is its purpose? What kinds of software testing are there? What is software metrics? What categories of measurement are there? What specific measures? What are the most frequent kinds of bugs you have encountered in this semester? What has been the hardest part about doing the project? What has been the hardest part about doing the coding? What methods worked, and what methods did not work very well? Is it harder to write new code, or to modify someone else's existing code? Why? What is CVS? How does it work? What are the major CVS commands? Suppose you get a "conflicts during merge" message from CVS; what causes it and what do you do about it? What other software tools did we use this semester? What do they do, how do you use them? Were there any C++ language features you had to learn this semester in order to implement your project? If so, what were they? Were there any problems related to using the language or class libraries?

Page 244: Question 1
Page 245: Question 1

Binary search Example

2 4 5 12 16 19 22 26 29 32 37 41 46 50

Looking for 46 Trial 1

2

3

2 4 5 12 16 19 22 26 29 32 37 41 46 50

2 4 5 12 16 19 22 26 29 32 37 41 46 50

Page 246: Question 1

Notes on Binary Searches

• List must be ordered (sorted)– can maintain a list in ordered fashion

• Much more efficient than linear– in example, took 3 iterations instead of 13– time ~ log2(listLength) – linear

• worst case ~ listLength• average ~ listLength/2

– for 100K words: 17 iterations versus 50,000

• More complex to program

Page 247: Question 1

SearchingThings To Know

• Be able to recognize and write a linear search

• Understand its pros and cons

• Know the concepts of a Binary Search

Page 248: Question 1

Questions

2 10 17 45 49 55 68 85 92 98

How many comparisons are needed to determine if the following items are in the list of 10 items?

linear search binary searchnumber15

49

98

2

10 3

5 1

10 4

1 3

(49, 10, 17)

(49, 85, 92, 98)(49, 10, 2)

(3, if know list sorted)

Page 249: Question 1

Sorting

• Put elements of an array in some order– alphabetize names– order grades lowest to highest

• Three simple sorting algorithms– selection sort– insertion sort– bubble

Page 250: Question 1

Selection Sort

• Sorts by putting values directly into their final, sorted position

• For each position in the list, the selection sort finds the value that belongs in that position and puts it there

Page 251: Question 1

Selection SortGeneral Algorithm

• Scan the list to find the smallest value• Exchange (swap) that value with the value in the

first position in the list• Scan rest of list for the next smallest value• Exchange that value with the value in the

second position in the list• And so on, until you get to the end of the list

Page 252: Question 1

Selection SortAt Work

98 68 83 7493

68 98 83 7493

68 74 83 9893

68 74 83 9893

68 74 83 93 98 SORTED!

Page 253: Question 1

Selection Sort

• Sorts in ascending order

• Can be changed to sort in descending order– look for max instead of min

Page 254: Question 1

Insertion Sort

• Like we’d actually sort things

• Insert each new item into an already sorted list

• Each unsorted element is inserted at the appropriate spot in the sorted subset until the list is ordered

Page 255: Question 1

Insertion SortGeneral Algorithm

• Sort the first two values (swap, if necessary)• Repeat:

– insert list’s next value into the appropriate position relative to the first ones (which are already sorted)

• Each time insertion made, number of values in the sorted subset increases by one

• Other values in array shift to make room for inserted elements

Page 256: Question 1

Insertion SortAt Work

98 68 83 7493

68 98 83 7493

68 83 98 7493

68 74 83 98 93

68 74 83 9398

SORTED!

Page 257: Question 1

Insertion Sort

• Outer loop controls the index in the array of the next value to be inserted

• Inner loop compares the current insert value with values stored at lower indexes

• Each iteration of the outer loop adds one more value to the sorted subset of the list, until the entire list is sorted

Page 258: Question 1

Bubble Sort

• "bubble"– largest values bubble to the end– smallest values sink to the beginning

• Idea– go through the list and swap neighboring items if

needed

• Pros– easy to understand and code

• Cons– horribly inefficient (listLength2)

Page 259: Question 1

Bubble SortAt Work

98 68 83 749368 98 83 749368 83 98 749368 83 74 9893

68 74 83 93 98 SORTED!

68 83 74 9398

Page 260: Question 1

Sort Implementations

• All three use double (nested) loops

• Selection and insertion– an outer loops scans all elements– an inner loop scans and switches/inserts as needed

• Bubble– an outer loop repeats until no swaps are needed– an inner loops scans and swaps as needed

Page 261: Question 1

SortingThings To Know

• Be able to recognize and follow an insertion sort, selection sort, and bubble sort

• Understand their pros and cons

• Know that many other sorts exist with varying efficiency and programming difficulty

Sorting animations (in Java of course!)http://www.cs.hope.edu/~alganim/animator/Animator.html

Page 262: Question 1

Question

Given the operation of the following sort, identify the type of sort (selection, insertion, or bubble)

34 21 97 15 8721 34 97 15 8721 34 15 97 8721 34 15 87 9721 15 34 87 9715 21 34 87 97

original

pass 1

pass 2

pass 3

pass 4pass 5SORTED

Page 263: Question 1

Question

Given the operation of the following sort, identify the type of sort (selection, insertion, or bubble)

34 21 97 15 8721 34 97 15 8721 34 97 15 8715 21 34 97 8715 21 34 87 97

original

pass 1

pass 2

pass 3

pass 4SORTED

Page 264: Question 1

SortingThings Other Than Numbers

• characters– same as integers (compare with < and >)

• Strings– use the built-in compareTo method

• Other Objects– we write a compareTo method– use the compareTo method

Page 265: Question 1

Recursion

• Recursive functions are defined in terms of themselves.– sum(n) = n + sum(n-1) if n > 1– Example:

• Other functions that could be defined recursively include factorial and Fibonacci sequence.

Page 266: Question 1

Recursion (cont.)

• A method is recursive if it calls itself.

• Factorial example:

• Fibonacci sequence example:

Page 267: Question 1

Recursion (cont.)

• Tracing a recursive method can help to understand it:

Page 268: Question 1

Recursion (cont.)

• Guidelines for implementing recursive methods:– Must have a well-defined stopping state– The recursive step must lead to the stopping

state.• The step in which the method calls itself

– If either condition is not met, it will result in infinite recursion.• Creates a stack overflow error and

program crashes

Page 269: Question 1

Recursion (cont.)

• Run-time support for recursive methods:– A call stack (large storage area) is created at

program startup.– When a method is called, an activation record

is added to the top of the call stack.• Contains space for the method parameters,

the method’s local variables, and the return value

– When a method returns, its activation record is removed from the top of the stack.

Page 270: Question 1

Recursion (cont.)

Figure 12-1: Activation records on the call stack during recursive calls to factorial

Page 271: Question 1

Recursion (cont.)

Figure 12-2: Activation records on the call stack during returns from recursive calls to factorial

Page 272: Question 1

Recursion (cont.)

• Recursion can always be used in place of iteration, and vice-versa.– Executing a method call and the corresponding

return statement usually takes longer than incrementing and testing a loop control variable.

– Method calls tie up memory that is not freed until the methods complete their tasks.

– However, recursion can be much more elegant than iteration.

Page 273: Question 1

Recursion (cont.)

• Tail-recursive algorithms perform no work after the recursive call.– Some compilers can optimize the compiled code

so that no extra stack memory is required.

Page 274: Question 1

Complexity Analysis

• What is the effect on the method of increasing the quantity of data processed?– Does execution time increase exponentially or

linearly with amount of data being processed?

• Example:

Page 275: Question 1

Complexity Analysis (cont.)

• If array’s size is n, the execution time is determined as follows:

• Execution time can be expressed using Big-O notation.– Previous example is O(n)

• Execution time is on the order of n.• Linear time

Page 276: Question 1

Complexity Analysis (cont.)

• Another O(n) method:

Page 277: Question 1

Complexity Analysis (cont.)

• An O(n2) method:

Page 278: Question 1

Complexity Analysis (cont.)

Table 12-1: Names of some common big-O values

Page 279: Question 1

Complexity Analysis (cont.)

• O(1) is best complexity.• Exponential complexity is generally bad.

Table 12-2: How big-O values vary depending on n

Page 280: Question 1

Complexity Analysis (cont.)

• Recursive Fibonacci sequence algorithm is exponential.– O(rn), where r ≈ 1.62

Figure 12-7: Calls needed to compute the sixth Fibonacci number recursively

Page 281: Question 1

Complexity Analysis (cont.)

Table 12-3: Calls needed to compute the nth Fibonacci number recursively

Page 282: Question 1

Complexity Analysis (cont.)

• Three cases of complexity are typically analyzed for an algorithm:– Best case: When does an algorithm do the

least work, and with what complexity?– Worst case: When does an algorithm do the

most work, and with what complexity?– Average case: When does an algorithm do a

typical amount of work, and with what complexity?

Page 283: Question 1

Complexity Analysis (cont.)

• Examples:– A summation of array values has a best,

worst, and typical complexity of O(n).• Always visits every array element

– A linear search: • Best case of O(1) – element found on first

iteration• Worst case of O(n) – element found on last

iteration• Average case of O(n/2)

Page 284: Question 1

Complexity Analysis (cont.)

• Bubble sort complexity:– Best case is O(n) – when array already

sorted

– Worst case is O(n2) – array sorted in reverse order

– Average case is closer to O(n2).

Page 285: Question 1

Binary Search

Figure 12-9: List for the binary search algorithm with all numbers visible

Figure 12-8: Binary search algorithm (searching for 320)

Page 286: Question 1

Binary Search (cont.)

Table 12-4: Maximum number of steps needed to binary search lists of various sizes

Page 287: Question 1

Binary Search (cont.)

• Iterative and recursive binary searches are O(log n).

Page 288: Question 1

Binary Search (cont.)

Figure 12-10: Steps in an iterative binary search for the number 320

Page 289: Question 1

Binary Search (cont.)

Page 290: Question 1

Quicksort

• Sorting algorithms, such as insertion sort and bubble sort, are O(n2).

• Quick Sort is O(n log n).– Break array into two parts and then move

larger values to one end and smaller values to other end.

– Recursively repeat procedure on each array half.

Page 291: Question 1

Quicksort (cont.)

Figure 12-11: An unsorted array

• Phase 1:

Page 292: Question 1

Quicksort (cont.)

• Phase 1 (cont.):

Page 293: Question 1

Quicksort (cont.)

• Phase 1 (cont.):

Page 294: Question 1

Quicksort (cont.)

• Phase 1 (cont.):

Page 295: Question 1

Quicksort (cont.)

• Phase 1 (cont.):

Page 296: Question 1

Quicksort (cont.)

• Phase 1 (cont.):

• Phase 2 and beyond: Recursively perform phase 1 on each half of the array.

Page 297: Question 1

Quicksort (cont.)

• Complexity analysis:– Amount of work in phase 1 is O(n).

– Amount of work in phase 2 and beyond is O(n).

– In the typical case, there will be log2 n

phases.

– Overall complexity will be O(n log2 n).

Page 298: Question 1

Quicksort (cont.)

• Implementation:

Page 299: Question 1

Merge Sort

• Recursive, divide-and-conquer approach– Compute middle position of an array and

recursively sort left and right subarrays.

– Merge sorted subarrays into single sorted array.

• Three methods required:–mergeSort: Public method called by clients–mergeSortHelper: Hides extra parameter

required by recursive calls–merge: Implements merging process

Page 300: Question 1

Merge Sort (cont.)

Page 301: Question 1

Merge Sort (cont.)

Page 302: Question 1

Merge Sort (cont.)

Figure 12-22: Subarrays generated during calls of mergeSort

Page 303: Question 1

Merge Sort (cont.)

Figure 12-23: Merging the subarrays generated during a merge sort

Page 304: Question 1

Merge Sort (cont.)

• Complexity analysis:– Execution time dominated by the two for

loops in the merge method

– Each loops (high + low + 1) times• For each recursive stage, O(high + low)

or O(n)

– Number of stages is O(log n), so overall complexity is O(n log n).

Page 305: Question 1

Design, Testing, and Debugging Hints

• When designing a recursive method, ensure:– A well-defined stopping state– A recursive step that changes the size of the

data so the stopping state will eventually be reached

• Recursive methods can be easier to write correctly than equivalent iterative methods.

• More efficient code is often more complex.

Page 306: Question 1

Summary

• A recursive method is a method that calls itself to solve a problem.

• Recursive solutions have one or more base cases or termination conditions that return a simple value or void.

• Recursive solutions have one or more recursive steps that receive a smaller instance of the problem as a parameter.

Page 307: Question 1

Summary (cont.)

• Some recursive methods combine the results of earlier calls to produce a complete solution.

• Run-time behavior of an algorithm can be expressed in terms of big-O notation.

• Big-O notation shows approximately how the work of the algorithm grows as a function of its problem size.

Page 308: Question 1

Summary (cont.)

• There are different orders of complexity such as constant, linear, quadratic, and exponential.

• Through complexity analysis and clever design, the complexity of an algorithm can be reduced to increase efficiency.

• Quicksort uses recursion and can perform much more efficiently than selection sort, bubble sort, or insertion sort.

Page 309: Question 1

Selection Sort Algorithm

• List is sorted by selecting list element and moving it to its proper position

• Algorithm finds position of smallest element and moves it to top of unsorted portion of list

• Repeats process above until entire list is sorted

Page 310: Question 1

Selection Sort Algorithm (Cont’d)

Figure 1: An array of 10 elements

Figure 2: Smallest element of unsorted array

Page 311: Question 1

Selection Sort Algorithm (Cont’d)

Figure 3: Swap elements list[0] and list[7]

Figure 4: Array after swapping list[0] and list[7]

Page 312: Question 1

Insertion Sort Algorithm

• The insertion sort algorithm sorts the list by moving each element to its proper place

Figure 6: Array list to be sorted

Figure 7: Sorted and unsorted portions of the array list

Page 313: Question 1

Insertion Sort Algorithm (Cont’d)

Figure 8: Move list[4] into list[2]

Figure 9: Copy list[4] into temp

Page 314: Question 1

Insertion Sort Algorithm (Cont’d)

Figure 10: Array list before copying list[3] into list[4], then list[2] into list[3]

Figure 11: Array list after copying list[3] into list[4], and then list[2] into list[3]

Page 315: Question 1

Insertion Sort Algorithm (Cont’d)

Figure 12: Array list after copying temp into list[2]

Page 316: Question 1

Bubble Sort Algorithm

• Bubble sort algorithm:

– Suppose list[0...N - 1] is a list of n elements, indexed 0 to N - 1

– We want to rearrange; that is, sort, the elements of list in increasing order

– The bubble sort algorithm works as follows: • In a series of N - 1 iterations, the successive elements, list[index] and list[index + 1] of list are compared

• If list[index] is greater than list[index + 1], then the elements list[index] and list[index + 1] are swapped, that is, interchanged

Page 317: Question 1

Bubble Sort Algorithm (Cont’d)

Figure 13: Elements of array list during the first iteration

Figure 14: Elements of array list during the second iteration

Page 318: Question 1

Bubble Sort Algorithm (Cont’d)

Figure 15: Elements of array list during the third iteration

Figure 16: Elements of array list during the fourth iteration

Page 319: Question 1

Outline of Today’s Tutorial

• Objective

• Introduction to C++

• Function

• Pointer

• Class

• Summary

Page 320: Question 1

Objective of tutorials

• To acquire adequate programming knowledge for the coming assignments

• To be able to turn ideas into codes• Programming in C++ (VC++ in Windows

environment)• I assume that most of you do not have any

experience in programming. I will start from those fundamental knowledge.

Page 321: Question 1

Objective of tutorials

• Attendance will not be counted towards your final score of the course, but you are strongly encourage to attend.

• Guidance and hints are provided for assignments and test preparation

• If you have any question, please post it on the newsgroup or approach to the TAs.

Page 322: Question 1

TA of COMP171

• Chan Ming-yuen [email protected] 4204

• Yihai SHEN [email protected]

• He Junfeng [email protected] 4204

Page 323: Question 1

What’s C++

• A programming language

• Data abstraction

• Object-oriented programming

• Generic programming

• Compiler translate C++ codes to a machine specific executable program (eg. VC++ in Windows)

Page 324: Question 1

Ideas to codes

• The art of programming

• From problems to solutions Problem solving technique Programming technique and style How to develop a program Use of various tools to help programming

• Practice makes perfect

Page 325: Question 1

How to create a Program

• Specify the problem – eg. Remove ambiguity and identify constraints

• Develop algorithms and design classes (OOP)

• Implementation – design, coding, debug.

• Documentation, testing, maintenance of programs.

Page 326: Question 1

Hello World

• Example: a “Hello World” program

Page 327: Question 1

Hello World

• #include statement makes libraries of classes & functions accessible to the program

• Compile needs access to interface, what the functions look like, but not the implementation.

• Documentation – comments on codes increase the readability. Cost of maintenance is always higher than that of development.

Page 328: Question 1

A More General C++ program

Page 329: Question 1

Functions• Reason: functions are

abstractions that help you to reuse ideas and codes – make the code clearer, more logical and comprehensible

Page 330: Question 1

Functions

• function prototyping: a description of the types of arguments when declaring and defining a function

• void funct(float x, float y, float z);

• Of course, you can choose not to have any arguments, void funct(void)

Page 331: Question 1

Functions

• Return values

• Example

Page 332: Question 1

Execution and Flow

• Execution of C++ program is organized around statements

Statements execute sequentially Or governed by control that repeats a

group of statement (loop). Eg. For, while..Or selected one of several groups to

execute. (if…else)A statement executes, it cause other

statements to execute (function calls)

Page 333: Question 1

Pointers & Dynamic Data

Page 334: Question 1

Pointer Variable

Page 335: Question 1

Dereference Operator

Page 336: Question 1

More Example

Page 337: Question 1

Pointer & Array

• Pointer and array are closely related in C++

• We can use a pointer to access the elements of an array

Page 338: Question 1

Pointer & array

Page 339: Question 1

Pointer & Array

Page 340: Question 1

Pointers & Constants

• When using a pointer, two objects are involved: the pointer itself and the object pointed to.

• Consider the difference between pointer to constant, constant pointer and constant pointer to constant

Page 341: Question 1

Pointers & Constants

Page 342: Question 1

Pointers and Constants

• Besides, the address of a constant cannot be assigned to an unrestricted pointer

Page 343: Question 1

References

• A reference is an alternative name for an object.

• The notation X& means reference to X

• Different from the previous ‘&’ which indicates the address

Page 344: Question 1

References

• Example

Page 345: Question 1

Reference

• To ensure that a reference is a name for something, the reference must be initialized

• Example

Page 346: Question 1

References

• Another example

Note that rr++ does not increment the reference rr (comparing with pointer), rather, it is applied to an int that happens to be ii

Page 347: Question 1

Reference

• Value of a reference cannot be changed after initialization

• Similar to a constant pointer (but cannot be manipulated the way that a pointer is)

• In the previous case, pp is a pointer and rr is a reference to ii

Page 348: Question 1

Function Revisited

• Usually, arguments are passed to function as input for manipulation

• Knowledge on pointers and references can be employed

• The manner that parameters are passed to the function can lead to different results

Page 349: Question 1

Parameter Passing

• Different ways to pass parameters into a function

• Pass-by-value, pass-by-address, and pass-by reference

• Ordinarily, arguments are passed by value to a function – a copy of the argument is made inside the function

Page 350: Question 1

Pass-by-value

Page 351: Question 1

Pass-by-address

• A pointer is passed instead of a value

• Pointer acts as an alias to an outside object

• Any changes to the alias in the function will be reflect to “outside” object

Page 352: Question 1

Pass-by-address

Page 353: Question 1

Pass-by-reference

• C++ provide another way to pass an address into a function – reference

• Similar to pass-by-address

• The effect of the reference is that it actually takes the address and passes it in, rather than making a copy of the value

Page 354: Question 1

Pass-by-reference

Page 355: Question 1

Class

• A tool for creating new types• Conveniently used as if the built-in type,

but user-defined• Derived classes and templates – related

classes are organized in a specific way according to their relationships

• Remember: Class is an abstraction of a group of objects, while an object is an instance of the class

Page 356: Question 1

Class

Page 357: Question 1

Class

Page 358: Question 1

Class – Member Functions

• Functions declared within a class definition

• Invoked only for a specific variable of the appropriate type

Page 359: Question 1

Class – Constructor

• A special function for the initialization of class objects

• It has the same name as the class itself

• Default or user-defined constructors

Page 360: Question 1

Class - Constructor

Page 361: Question 1

Class – Access Control

• Three keywords/categories: public, private and protected

• public means all member declarations that follow are available to everyone

• The private keyword, means that no one can access that member except you, the creator of the type, inside function members of that type

Page 362: Question 1

Class – Access Control

• Protected acts just like Private, except that it allow the inherited class to gain access.

• Example

Page 363: Question 1

Summary

• Topics covered in this tutorial: Function, Class, Pointer, Reference, etc

• For more details, please refer to your lecture notes ,texture book and references

• Of course, I am looking forward to having your feedback on the tutorials (for example, Is there any interesting problem that you want me to address in the tutorial)

Page 364: Question 1

This week's topics

• Sorting– Selection, bubble, and insertion sort

• Profiling and analyzing sort algorithms

• Searching– Linear search– Binary search

Page 365: Question 1

Sorting

• Often useful and necessary to sort information (alphabetical order, numerical order)

• Ordering of information helps the process of evaluation, searching, and selecting data.

• What types of data do you know that is typically sorted?

• Simple sort algorithms are:– selection sort– bubble sort– insertion sort

Page 366: Question 1

Selection Sort

• Given an unsorted array of numbers, sort them in order smallest to largest

• Algorithm:– Compare the first array element with the smallest of the remaining

elements. If the first element is larger, then swap them. Otherwise, leave them alone.

– When done, the first element in the array will be the smallest.

– Repeat, starting with the second element of the array.

– Repeat for entire array up to the next to last element.

Try on: 35 4 17 2 How does this algorithm change to sort from largest to smallest?

Page 367: Question 1

Bubble Sort

• Given an unsorted array of numbers, sort them in order smallest to largest

• Algorithm:– Compare the first two elements of the array. If the first element is larger

than the second, then swap them. Otherwise, leave them alone.

– Repeat this step for the second and third element, then the third and fourth, and so on.

– At the end of the first pass, the last number in the array is the largest.

– Repeat for as many times as there are elements in the array.

Try on: 35 4 17 2 How does this algorithm change to sort from largest to smallest?

Page 368: Question 1

Insertion Sort• Given an unsorted array of numbers, sort them in order smallest to largest• Algorithm:

– Start with the first element of the array. At this point, this first element is sorted. – Compare second element of array with the first element. If the first element is

larger than the second, then swap them. Otherwise, leave them alone. At this point, the first two elements are sorted.

– Compare third element of array with the second element. If the second element is larger than the third, then swap them and compare the second with the first element, swapping again if necessary. If no swap is necessary, this step is done and the first three elements in the array are sorted.

– Repeat for entire array.

Try on: 35 4 17 2How does this algorithm change to sort from largest to smallest?

Page 369: Question 1

Profiling sort algorithms

• What is the efficiency of the sort algorithms? Which is the best to use?

• Profiling is one way to determine. Can use system clock to get time of execution in milliseconds: – Get CPU clock time (t1)

– Run sort method

– Get CPU clock time (t2)

– Sort time (approximately) is t2 – t1Selection soft graph results with increasing size of numbers to sort:

Time

numbers

Parabola shape. Double data results in four-fold increase in time.

Page 370: Question 1

Analyzing sort algorithms

• Can also determine time by analyzing how many times each array element is visited during search.

• Number of visits for selection sort (n numbers): ½ n2 + 5/2 n – 3

• As n gets bigger, fastest growing term is n2, so rest of equation can be ignored.

• Selection sort considered O(n2) algorithm - this is called Big-Oh notation

• Selection sort, Bubble sort, and Insertion sort are all O(n2)algorithms

Page 371: Question 1

Searching

• When there are a large number of items to search, it is often necessary to have a strategy for finding a specific item.

• What examples can you think of for searching out an item? • Does it help if the items are ordered or arranged? • Two simple searching techniques are the linear search and the

binary search.

Page 372: Question 1

Linear Search

• A linear search looks through list from the beginning until it encounters the desired item.

• If the list is sorted, the search process can end when a value greater than the one sought out is found.

int foundIt = -1;

for (int i = 0; i < array.length; i++)

{

if (array[i] == searchValue)

{

foundIt = i;

break; // out of for loop

}

}

// at this point, foundIt holds position of item or –1

Linear search is O(?) algorithm

Page 373: Question 1

Binary Search“Divide and Conquer”

• A binary search assumes you start with a sorted list. • Algorithm:

– The list is divided in half to find the mid-point.

– At this mid-point, one of three states exist:

1. You have found the item.

2. The item is less than the mid-point.

3. The item is greater than the mid-point.

– If the value sought is not found, divide the remaining space in half and find a new mid-point.

– Repeat until you find the item or run out of space to divide.

Code for binary search is in BigJava pg. 652

Binary search is O(logn) algorithm

Page 374: Question 1

Next Week

Be sure to review the course schedule for new assignments and assignments that are due.

Page 375: Question 1

Question :Is the following statement a declaration/definition. Find what does it mean? int (*x)[10]; Answer:Definition. x is a pointer to array of(size 10) integers. Apply

clock-wise rule to find the meaning of this definition. Question :What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

Answer:Compiler error: Multiple declaration for error The name error is used in the two meanings. One means that it is a enumerator constant with value 1. The another use is that it is a type name (due to typedef) for enum errorType. Given a situation the compiler cannot distinguish the meaning of error to know in what sense the error is used: error g1; g1=error; // which error it refers in each case? When the compiler can distinguish between usages then it will not issue error (in pure technical terms, names can only be overloaded in different namespaces). Note: the extra comma in the declaration, enum errorType{warning, error, exception,} is not an error. An extra comma is valid and is provided just for programmer�s convenience.

Page 376: Question 1
Page 377: Question 1
Page 378: Question 1
Page 379: Question 1
Page 380: Question 1

#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

Answer:Compiler error : undefined symbol some This is a very simple example for conditional compilation. The name something is not already known to the compiler making the declaration int some = 0; effectively removed from the source code.Question :#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

Answer:0 0 This code is to show that preprocessor expressions are not the same as the ordinary expressions. If a name is not known the preprocessor treats it to be equal to zero.