0% found this document useful (0 votes)
296 views16 pages

Computer 3-2014 t2

Computer 3-2014 t2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
296 views16 pages

Computer 3-2014 t2

Computer 3-2014 t2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
Alexandria University Ayystsuyl deal Faculty of Engineering Heasigh dass Computer and Systems Engineering Dept. ay uta La pad Database Systems (CS 322) Gig eis Third Year Ferre) June 2014 Ve) tssiae Time: 3 hours loka Ys asl ‘Answer the following questions: Full Mark = 90 Points Question One: (35 Points} You are required to design a database for an online movie-rental system. The system has 2 types of users; customers and administrators. A customer is any user interested in renting a movie. The administrators control the movie inventory. Each user in the system must have a unique user name and a password. To add a new movie, an administrator must add a movie fitle, a release year, a director, at least one actor and at least one genre. The name and biography of actors/ directors are kept. It should be noted that an actor in a movie can be a director of another movie. A movie entry can include award(s) of the movie (if any). Assume that there are five different types of awards (e.g., Oscar, Golden Globe,...). Every award can be divided into 2 groups; movie awards and actor awards. There are 8 categories of movie awards and 4 categories of actor awards. A movie award will be associated with a movie and a year, while an actor award will be associated with a movie, an actor in the movie and a year. For a given year and a given award category of an award type (c.g. Oscar for Best Picture) only one award is given. The year of an award can be different from the year a movie is released. A movie can have many copies for rent. When a new copy is added, a unique ID will be automatically generated for it. Before using the system, a customer has to be registered by submitting a unique user name, a password, his full name and a mailing address. The system allows a registered customer to browse the list of movies and select a movie to rent. The movie list contains the movie’s title, year, director, total number of awards and the number of copies available for rent. Clicking on a movie title shows the detailed info of the movie. To rent an available movie, the customer has to enter his credit card type, number and expiration date into a special form. A customer can’t have more than 5 currently rented movies altogether. The rent order date is kept and the status of the order will be “In Process”. The status of the order will be changed to “Delivered” after an administrator checks out the order. A copy of the movie is then delivered to the customer. When a movie is retumed by a customer, the return date is kept. A customer can always view a status and /or a history report of his rented movies. A status report shows the list of movies currently rented to that customer, including the order date, movie title and order status for each one. A history report shows list of the customer's rented movies in the last 3 months including the movie titles and the corresponding order and return dates. For the above problem, do the following: a- Design and draw an Enhanced Entity Relationship Diagram (EERD). be Map the EERD in (a) to a relational schema (you may make any required assumptions). Question Two: (25 Points| Consider the relations E(ssn, ename, salary, did), W(essn,ppno, hours) and P(pno, pname, budget, loc), having 10,000, 20,000 and 2000 records, respectively. The blocking factors for E, W and P are 200, 500 ‘and 200 records/ block, respectively. Assume that Min (salary) =10,000, Max (salary) =30,000, Min (budget) = 500,000 and Max (budget) = 1,000,000. Assume also that there are 10 distinct values for ” attribute [Link] and 10,000 distinct values for attribute [Link]. There is a clustering index on [Link], a primary index on [Link], and secondary indexes on [Link], [Link] and [Link]. Each index has 2 levels. Assume that the distribution of attribute values in each relation is uniform and that conditions on attributes are independent. Consider the following query, SELECT ename, pname FROME, W, P WHERE ssn = essn AND ppno=pno AND (salary BETWEEN 19800 AND 20000) AND budget > 600000 AND loc = ‘Cairo’; a- Estimate the cost of processing the selection condition (salary BETWEEN 19800 AND 20000) on relation E. b- Estimate the cost of processing the conjunctive selection condition (budget > 600000 AND loc on relation P. Estimate the number of records that satisfy this conjunctive condition. Cairo’) c For the above query, consider only the join order E ce Weo P. Assume the existence of 12 buffer blocks for implementing the join and that a materialization approach is used. Assume that the query optimizer performs only the selection on E before join and performs the selection on P on the fly (during join). Assume also that the projection is done on the fly. Suppose that the number of records resulting from joining E and W equals 400 records and that bfrew = 100 records/block. Given the above assumptions, find the plan that has the least estimated cost for processing the query in the given join order and get its cost (ignore the cost of writing out the final result). Question Three: (15 Points) Consider the three transactions T1, T2 and T3. The operations of these transactions are given below. Assume that all previous transactions were committed when T1, T2 and T3 begin execution. Ti: rl(X) wI(Y) C1 T2: w2(¥) w2(X) C2 T3: w3(¥) C3 - Give an example of an interleaved schedule of the 3 transactions that is recoverable and conflict serializable, Show the corresponding precedence graph. b- Give an example of an interleaved schedule of the 3 transactions that is cascadeless (i.e., avoids cascading rollback), but not conflict serializable. c- Assume that the actions of the 3 transactions are submitted to a DBMS in the following sequence: ¥1(X) w2(Y) w2(X) w3(Y) wl(Y) Cl C2 C3. ‘Assume that the concurrency controller applies a rigorous two-phase locking (2PL) protocol using the Wound-Wait deadlock prevention technique. Assume also that the timestamp of transaction Ti is i and that a wounded transaction will be restarted after the termination of the conflicting transaction. Show how the concurrency controller handles the given sequence. Justify your answer. Question Four: (15 Points} a-Consider the relation Book( Book title, Author, Book type, Price, Author_affil, Publisher). It has the following functional dependencies: Author > Author_affil and Book_type —+ Price i- State the strongest normal form of the relation Book. Justify your answer. ii- IF Book is not in BCNF, find a decomposition of it into a set of BCNF relations. b- Assume that a database recovery manager applies a no-steal / no- force strategy. There are many ways to implement this strategy. In one implementation, when a data item is written by a transaction, its new value is not recorded in the DB cache at that time. This happens only afier the transaction commits. The Jog buffers (in the cache) can be organized as a set of ‘intention lists’, one per transaction. The intention list of a transaction T; contains the new values of all data items updated by Tj. If T; aborts, its intention list is discarded. If T, commits, its intention list is marked ‘committed’ and flushed to stable storage. For the recovery manager described above, outline the actions for Write, Commit and Restart (from system failure), assuming an in-place updating strategy, a rigorous 2PL and a Write-Ahead-Logging (WAL) protocol. ‘Alexandria University - Faculty of Engineering Department of Computer and Systems Engineering Course: C5 312 (Operations Research) Final Exam (Open Book ~ Open Notes) June 2014 Time: 3 hours answer Five Questions of the following Q1. [18 points} Jungle Figures, Inc. produces two models of +59 stuffed giraffes which ee rein high-end zetail stores. The large giraffe requires 2 pounds of stuffing A at and requires 6 minutes of machine time, whereas the sat) giraffe requires T pound of stuffing material, but because of a tighter ‘stitching pattern it must be 2 Etched twice, thus requiring 12 minutes of machine time. There Are 800 pounds of ecarsire) snail a0) mack ne) bouzakava abl ener Neues a !aceripenc aca policy of not Producing more than twice the nunber of large giraffes o¢ small giraffes, Jungle Figures Rees ceenran ia eoifeel tte) Ore) Gtzattes) te eeetare a oe Uae aa giraffe and $9 per small gizaffe rormilate a linear progranming model that maximizes Jungle Figures’ weekly profit from the manufacturing of the giraffes 2. [18 points] A night watchman must make his rounds to four sacs of a plant each Geo ’gnen reaches an area he inspects it and punches in on @ Fine clock to verify peer aspection. He then returns to the lobby where he sits down and watches television Given the time between locations (in minutes) in the table Pelow! Ot which order ghatis he inspect the areas if his objective is to maximize his television time? Aiea i | Area 2 | Brea 3 | Area 7] [et | {- + ee i Q3. {28 points] The Red Rock School District has six buses in its fleet. Maintenance 03 et leet is handled by Joe Clem, a mechanic who works for the distsict Buses will cee in to this mechanic according to a Poisson distribution with 2 Fate of one bus Nery twenty days. During the time a bus is out of commission: The district must lease Cee ewer at a cost of $80 per day. Joe has put in for retirement and the district anos ae ring hising either Tom Mayers or Andy Johnson. Based on = skil15 assessment eee te fs estimated that Tom can repair a bus in an average of 20 hours, while Andy wet’ cake an average of @ hours. Tom wants a salary equivalent to $160 per working Say, while Andy wants a salary equivalent to $170 per working day. & working day lasts aay aie d there are 200 working days per year. Which employee should the district hire? Give your reasons. page 1 of 2 Q4. [18 points] Bpac fills 80,000 water bottel monthly. It currently purchases the plastic bottle from Moore Plastic. The bottles cost Epac $.045 each and the cost to place an order with Moore is estimated to be $150. Approximately a half percent of all bottles delivered by Moore are defective so that Epac must order 80,402 (80,000/.995) bottles to support its production. Epac is considering producing the plastic bottles in-house. It can do this by leasing a plastic bottle machine at a cost of $9,000 per year which is capable of producing 200,000 plastic bottles per month, The production set up cost to use this machine is $200 and the incremental production cost of bottles is §.038. In this case there will be no defective bottles. Epac estimates its holding cost rate for bottles is 20% whether they are purchased or produced in-house A. What is Epac's optimal purchase or production quantity? B. Determine whether Epac should continue to purchase bottles from Moree or begin in-house production if their objective is to minimize the cost of water bottle Production. Q5. [18 points] Suppose that a cell phone customer has a choice of four monthly leasing plans: Plan I: $20 per month and $.40 per minute Plan II: §30 per month with 20 free minutes and $.30 per additional minute Plan ITI: $40 per month with 30 free minutes and $.20 per additional minute Plan Iv: $60 per month with 100 free minutes and $.10 per additional minute Suppose also that the customer estimates that the amount of time he will talk on the cell phone each month can be approximated by the following distribution: 100 minutes 150 minutes Which plan the customer should choose to minimize the expected monthly cost? Q6. [18 points] The new community of Lemon Heights is planning to set up a paramedic station. It is estimated that calls will come in to this station according to a Poisson distribution and the station receives an average of twenty calls a day. The time an ambulance is out responding to a call follows an exponential distribution with a mean time of one hour and thirty minutes. If no ambulance is available, an ambulance fron a nearby town will be dispatched, but this will significantly increase the response time. Due to the potentially tragic consequences associated with not having an ambulance readily available when a call comes in, the city council has mandated that the probability of this happening should be no more than .005 Determine how many ambulances the paramedic station should purchase. Good Luck, Or Yousry Taha Page 2 of 2 Jexandria University aculty of Engineering Somputer and Systems Eng Department ‘gy inal exam for the second term 2014 ‘bird Year rogramming Languages and Translators ‘ime allowed: 3 hours Answer All Questions: Full mark = 90 Points Question One: (15 Points) 2) points) ¥ = {a, b, ed}. Write a context-fiee grammar (CFG) for the language described by the regular expression ((ab)"(cld))" ) (9 points) Let = {a, be}. Write a context-free grammar (CFG) for the language described by: A= (albick |i = jor j= kwhere i,j,k 20} Is your grammar ambiguous? Why or why not? juestion Two: (15 Points Consider the following grammar with terminals [, ],, b, ¢, +, and ~: sa (sxa X 4S IYbI€ Y>-SXcl€ a) (6 points) Compute first and follow sets for all nonterminals. b) G points) Construct the predictive parsing table for the given grammar, assuming panie-mode error recovery. ©) (5 points) Using the parse table in (b), trace the moves made by the predictive parser for the input [ata-ac] by filling the following table. [ Stack Input. ‘Action T Question Three: (20 Points) ee wing grammar generates binary numbers (numbers in binary representation) with a binary radix point (fractional point) SPLLIL L>LBIB BDO|1 1/3 Alexandria University Ayweuyl daly Faculty of Engineering aig UIs. Computer and Systems Eng Department pally caudal asia pad Final exam for the second term 2014 2014 AN gall al Lyi gai Third Year in dy Programming Languages and Translators Cha fall pall 5 Time allowed: 3 hours Sel CO: a5) ®) (6 points) Design an SDD to compute [Link], the decimal number value of an input binary string. For example, the translation of string 110.01 should be the decimal number 6.25. ») (4 points) Draw the annotated parse tree for the input string 101.1. ©) (S points) Remove left recursion from your SDD. 4) (5 points) Using the grammar in c), draw the annotated parse tree for the input string 101.1 Question Four: (20 Points) Consider the following syntax-directed definition over the grammar defined by G = ({S, A, Sign}, S, (‘7, “‘, “+, ‘n’}, P) with P the set of production and the corresponding semantic rules depicted below. The terminal symbol “n” is lexically matched by any string of one numeric digit and whose value is the numeric value of its decimal representation. For the non-terminal symbols in G we have defined two attributes, sign and value. The non-terminal A has these two attributes whereas S only has the value attribute and Sign only has the sign attribute. S—A Sign [Link] = A-val; A sign = Sign sign; print([Link]), Sign > + [Link] = I Sign > - [Link]=0 A-n ‘Aval = value(a) A>Aln ‘[Link] = [Link]; if([Link] = 1) then [Link] = min ([Link],value(n)); else [Link] = max([Link],value(n)); For this Syntax-Directed Definition answer to the following questions: a) (5 points) Explain the overall operation of this syntax-directed definition and indicate (with a brief explanation) which of the attributes are either synthesized or inherited. b) (10 points) Give an attributed parse tree for the source string “5,2,3-“ and evaluate the attributes in the attributed parse tree depicting the order in which the attributes need to be evaluated (if more than one order is possible indicate one.) ©) G points) Suggest a modified grammar and actions exclusively using synthesized attributes. Explain its basic operation. 23 lexandfia University Asis) dead, aculty of Engineering Aussigll US. Jomputer and Systems Eng Department ‘nal exam for the second term 2014 2014 3) ala Seal gi gai bird Year ama ‘ogramming Languages and Translators nals ool oe ime allowed: 3 hours oe testion Fi 25 Point Consider the following grammar for the assignment and repeat statements: stmts > stmts stmt | stmt stmt [Link] | if_stmt |repeat_stmt [Link] + var := exp if_stmt + if (B) ass_stmt case_stmt case var of select_list end select_list > label : stmt; [Link] | label : stmt label > num | other exp exp addop exp | id | num var > id Bo > B&&B | BIB | exprelexp | true | false a) (12 points) Write an attribute grammar for generating three-address code for the above grammar. Make sure to define any attribute you use. ) (7 points) Give the sequence of three-address code instructions corresponding to the following if statement using the above attribute grammar: if(x>10 |Ix20) f:=2 ©) (6 points) Give the sequence of three-address code instructions corresponding to the following fragment using the above attribute grammar and the code generated for the Boolean expression in part b). f case t of Li fa; 2: if(e>10 IIx20) fs other: f :=3 end 3/3 Alexandria University Ay yaisuyl deal, Faculty of Engineering Hassight ls Comp. & Sys. Engineering pay Gaal Laas pa Embedded systems Kgase pi Third Year ants) 23 i June 2014 TeV sai Time: 3 hours esa Y :Ga3 ‘Answer all the following questions: (Full mark 90) juestion one: Choose the correct answer (50 marks) 1. For reconfigurable logic (FPGA), the number of operations per Watt is larger than any other technology. (True - False) 2. Reducing energy consumption in embedded systems improves reliability. (True - False) Loop unrolling increases program execution speed. (True - False) 4. Runtime efficiency can be realized by customizing architecture to certain applications (example is the Digital Signal Processing). (True - False) 5. In logic circuits, tree structure has more glitches than chain structure. (True - False) 6. A patient monitoring system in an ICU (Intensive Care Unit) is systems. (soft - hard) 7. Dynamic scheduling takes decisions at runtime. (True - False) wversion will occur even if we have only ONE single semaphore in whole system. (True - False) 9. With the Priority Ceiling Protocol, a thread might NOT be able to enter a Semaphore even ifitis available. (True - False) 10. (priority inversion) If we have three threads (i.e, ty, tw, t,) with different priorities (ie., HIGH, MIDDLE, & LOW, respectively) and a semaphore S is shared between ty and t,, then, ty might indirectly block ty even if they don’t share any semaphore. (True - False) real time 11. With PCP (Priority Ceiling Protocol), the priority ceiling value of a semaphore S is “ equal to the assigned priority of the first thread entering the semaphore. (True - False) 12. The idle task has the lowest possible priority. (True - False) 13. The given circuit shows a pushbutton SI connected to an AVR port that will provide a logic ......... When the switch is pressed. (0 ~ 1) 14. You have a choice of a fast clock (1.8 GHz MHz) or a slow one (100 MHz) for a battery-powered system. You calculate the load on the system and find that either $14 ‘one has sufficient processing power for the intended applications. What clock will L ‘you choose? ( fast-slow) why? 15. The primary goal when designing a hard real-time system is to minimize the average response time of the tasks. (True - False) Ri 16. A piezoelectric speaker is a sensor. (True - False) 17, The main function of the AVR input capture is to generate time delays. (True - False) 18. A phototransistor might be used as a sensor connected to a microcontroller to control a small DC motor directly when daylight occurs. (True - False) 19. Many home entertainment devices such as televisions, stereos, and DVD players can be operated wirelessly utilizing infrared remote controls. But the infrared signal must have an unobstructed path to the receiving component. (True - False) 20. Three independent periodic control tasks are used. Their periods are 10, $0, and 100 ms respectively, and their execution times are 2, 25, and 15 ms respectively. Are they schedulable? a. Yes. b. No. ec. May be. 21. Ina servo motor, how does the motor rotate to the desired position? ‘a. By the magnitude of the pulse sent via the control wires. b. By the frequency of the waveforms sent via the control wires. c. By the duration of the pulse sent via the control wires. 4._ Non of the above. 22. The following factors affect switching activity value except a. logic function c. loading capacitance b. dynamic glitches 4. inter-signal correlation 23. A “watch-dog timer” enables the implementation of real-time systems by providing a regularly timed interrupt for starting real-time tasks. 1 very flexible interrupt which is set for individual, critical real-time tasks. a time-of-day alarm to synchronize all tasks at a fixed time. a mechanism for system recovery if any task takes too long to complete (ex. infinite Toop). 24. Input ordering affects switching activity value. Assume 3 variables, A, B and C with the following probabilities (of being 1) 0.7, 0.2, 0.5 respectively, then the best reordering to reduce power is a. ABC ©. ACB © BCA b. BAC 4. CAB 25. In Rate Monotonic Scheduling a. shorter duration task has higher priority. b. longer duration task has higher priority. c. priority does not depend on the duration of the task. 4. none of the above. Question two: (15 marks) 1. (4 marks) Show the initialization of TCCRIA (Timer/Counter1 Control Register), OCRIAH and OCR1AL (Output Compare Register) needed to generate a PWM signal on (OCI) of the 2313 microcontroller with duty cycle 25% and 10-bit resolution. 2. (3 marks) An 8-bit ADC has a reference voltage of 12 V (min. voltage is 0 V). Ifan analog voltage of exactly 8 V is input to this device, what is the digital code output in hex? 3. (S marks) Consider a microcontroller timer unit with a 16-bit counter operating with a 40MHZz clock. Assuming a 1:1 prescale is chosen, what is the time occurs between interrupts of timer overflows? What is the time if prescale is 1:87 5. (3 marks) It is required to design an embedded system. It has two input switches (START & RESET), 3*4 keypad, single LED and a seven-segment display. How many VO pins are required. Show the step(s) to get the answer. Question three: (7 marks) 1. Self-study part G marks) Explain how to design an infrared heart-rate sensor. 2. (4 points) Show the timeline to schedule the following aperiodic tasks using EDF (Earliest Deadline First) scheduling. arrival | duration | deadline Taski_| 1 3 im Task [313 10 Task3_|0 14 21 Task | 9 2 16 TECRIA - Timer/Counter 1 Control Register ($2F) Bitno. 7 6 5 4 3 2 1 0 Bitname COM1A1 COM1AQ - - - - PWMIt PWM10 —_l aa 00 |PWM mode disabled 01 |8-bit PWM enabled 10 |9-bit PWM enabled ! 14 [10-bit PWM ena! 1 |10-bit PWM enabled | ee } When in PWM mode... 00| Do nothing to OC1 pin 01] Do nothing to OC1 pin 10| Clear OC1 when counting up, set OC1 when counting down 11] Set 0C1 when counting up, clear OC1 when counting down ‘When not in PWM mode... 00} Do nothing to OC1 pin 01} Toggle OC1 when Output Compare interrupt occurs Ju} Clear GCi when Gutput Compare interrupt occurs 11] Set OC1 when Output Compare interrupt occurs Output compare . On the 2313, for example, the value that is to be compared with T/C1 is stored over. two 1/0 registers: OCRIAH and OCRIAL (which stand for Output Compare Register ‘A for TIC1, Higher and Lower bytes respectively). yn four: (18 marks) Questio 1 2. ‘G marks) Explain briefly the Dynamic Power Management for microprocessors. G parks) Consider a 2-input NAND gate, and let P, and Pp be the probabilities that the inputs A and B are one respectively. Assume that the inputs are not correlated. Find a at the NAND output {G marks) An energy efficient processor has two power modes: a run mode where the power consumption is Paa = 100mW and a sleep mode where Pay ~ OmW. The ponsition from the run mode to the sleep mode takes 1 ms and costs 10 J. The same applies also for the transition from sleep mode to run mode. What is the minimal idle interval (break-even time), for which itis feasible and worth transiting to sleep mode to save energy? (G marks) consider the following code i=0; i" De Good Luck Dr. Salah Selim and Dr. Layla Abou-Hadeed Alexandria University Faculty of Engineering Comp. & Sys. Engineering Ally Guta aaa ad Computer Arch. CSx35 ual 5 lee Third Year Poriecery May 2014 2014 ge Time: 3 hou sels 3 rca! ‘Answer all questions: (Full Mark = 90 points .all questions equal marks) Question one: a+ Give a piece of code to demonstrate temporal locality. be Give a piece of code to demonstrate spatial locality c= Keeping the cache size fixed. is wide-line. or narrow-line better, for temporal locality ? d- Keeping the cache size fixed, is wide-line, or narrow-line better, for spatial locality e. For direct mapped cache. how do we find the location in the cache for a certain memory address ? {How do we know whether the data in the cache location actually belongs to the requested memory address, or to another memory address? g- What actions should be taken in the following cases? Data cache read hit. Data cache write hit, Instruction cache read miss. Question tw: For a certain processor we have the following: memory byte- address is 32 bits. cache is direct mapped. Word is 4 bytes. number of cache lines (blocks) is 256. Line is 4 words. a- Give the total size of the cache in bits. be Give the fields of the memory address, and their sizes, c- A processor has CPI 2 (without considering cache misses). miss penalty is 100 cycles, If the cache miss ratio is 10%, calculate the actual CPI ( by adding the effect of the miss penalty). de We have two direct-mapped cache systems:- system | is 4 lines, the line is a single word. system IT is 2 lines, the line is 2 words. ifwe start with blank cache find the miss ratio for the following memory address sequence (for both systems). 0.1.2. 4.12013, 12,120 Which system is better, why? If the hit time is 1 cycle, miss penalty 10 cycles, find AMAT for each. 12 Question thre ‘a- Draw the single cycle datapath for the MIPS processor. Indicate on the drawing the stages involved in an R-type instruction, Assuming all the components consume 20 n-sec find the critical path, and calculate the instruction time. b- Does pipelines improve throughput or latency? If the stages of the pipeline have the same delay, n-stage-pipeline gives a speed up by how much? c- What is the difference between pipeline stall, and purge (flush)? When is each used? Question four: ‘a List 3 types of hazards, and give instruction squence for each, b- Data forwarding solves which type of hazards? Give example Question five: a- Define throughput and response time and the units of each. b- For computer A with 2GHz clock, a program takes 10s, For computer B (uses clock cycles x 1.2), the same program takes 6s, What is the clock rate of Computer B? c- Computer A: Cycle Time = 250ps, CPI = 2.0 Computer B: Cycle Time = S00ps. CPI = 1,2, same ISA. Which is faster, and by how much? Seconds Clock cycle CPU Time — instructions , Clock cy Program ~ Instructi ad Ic x Chl x ic Referring to the above formula, which of the following affects each of the three factors? Algorithm, compiler. ISA Good Luck Dr. Hussein Dr. Salah, Dr. Ibrahim Alexandria University Ayal dada, Faculty of Engineering Huaaight Als Department of CSE Ally Gull Laasia pu Spring 2014 Ve E/T NT cg gal yl uch Data Structures II Yc Sst Final Exam pull SAT gata Allotted Time: Three Hours lel 205 245i Attempt all the following questions. QUESTION ONE {15 pts Consider the snapshot of the Linear Hashing index shown in the figure below. Assume that a bucket split occurs whenever an overflow page is created. ‘a) What is the maximum number of data entries that can be inserted (given the best possible distribution of keys) before you have to split a bucket? Explain very briefly. b) Show the file after inserting a single record whose insertion causes a bucket split. 3 i) What is the minimum number of record insertions that will cause a split of all four buckets? Explain very briefly. ii) What is the value of Next after making these insertions? iii) What can you say about the number of pages in the fourth bucket shown after this series of record insertions? hy | ho 000 | 00 ot | ot 9 [as or | 10 7] on} oa | ne]? [3 QUESTION TWO [15 pt 1a) When does a buffer manager write a page to disk? b) What is sequential flooding of the buffer pool? ©) Consider a list-based organization of the pages in a heap file in which two lists are maintained: a list of all pages in the file and a list of all pages with free space. What are the trade-offs between the above organization and the list-based organization discussed in the textbook? QUESTION THREE [15 pts}: 1. Solve the recursive relation: T(0) = 1 and T(n) = T([.9n]) + O(n)- 2, Given k binary search trees, with a total of n items. Show how to merge the items in these trees to form one balanced tree in O(nlog k) time. Knowing that the sizes of the k trees are 2,4,8,...2* show how to do the merging in O(n) time. QUESTION FOUR [15 pts}: 1. Show the result of inserting 7,3,1,5,6,4,10,2,9,8 in an AVL tree 2, Show that the number of nodes of a binomial tree of rank r is 2", and that there are ( T ) nodes at the ith level (the root hes level 0). Show how to represent such thee sing two pointers per node QUESTION FIVE (15 pts}: ! 1, Prove that the edge with the largest weight on a cycle in a weighted graph cannot be on the minimum spanning tree of the graph. 2, Given a graph with n vertices and m edges, where the weights on the edges re positive integers the value of each is at most n. Suggest an efficient way to find the eenimurn spanning tee of this graph, and analyze the running time of this method. QUESTION SIX [15 p 1, Write the pseudo-code for # recursive procedure that implements depth-first search in a directed graph. 2, Given a directed weighted graph, and a directed tree T rooted at a vertex s. Design cihsear-time algorithm to verify whether T is a shortest-path tree from the single- ‘source 8. Prove in details the correctness of your algorithm.

You might also like