24 Pages

lect04

Course: COMPUTER S 320, Spring 2012
School: Sakarya Üniversitesi
Rating:
 
 
 
 
 

Word Count: 763

Document Preview

trees anhtt-fit@mail.hut.edu.vn Symbol Red-black Table Review Symbol table: key-value pair abstraction. Insert a value with specified key. Search for value given key. Delete value with given key. Different implementations Array Linked list BST (binary search tree) Complexity Randomized BST. Guarantee of ~c lg N time per operation (probabilistic). Need subtree count in each node. Need random...

Register Now

Unformatted Document Excerpt

Coursehero >> Other International >> Sakarya Üniversitesi >> COMPUTER S 320

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
trees anhtt-fit@mail.hut.edu.vn Symbol Red-black Table Review Symbol table: key-value pair abstraction. Insert a value with specified key. Search for value given key. Delete value with given key. Different implementations Array Linked list BST (binary search tree) Complexity Randomized BST. Guarantee of ~c lg N time per operation (probabilistic). Need subtree count in each node. Need random numbers for each insert/delete op. 2-3-4 tree 2-3-4 tree. Generalize node to allow multiple keys; help to keep tree balanced. Perfect balance. Every path from root to leaf has same length. Allow 1, 2, or 3 keys per node. 2-node: one key, two children. 3-node: two keys, three children. 4-node: three keys, four children. Search Compare search key against keys in node. Find interval containing search key. Ex. Search for L Insert (1) Search to bottom for key. Ex. Insert B Insert (2) 2-node at bottom: convert to 3-node. 3-node at bottom: convert to 4-node. Ex. Insert B Transformation Local transformations should be applied to keep the tree balanced. Ensures that most recently seen node is not a 4-node. Transformations to split 4-nodes: Growth of a tree Growth of a tree (cont.) Complexity Worst case: lg N [all 2-nodes] Best case: log4 N = 1/2 lg N [all 4-nodes] Between 10 and 20 for a million nodes. Between 15 and 30 for a billion nodes. Red-black tree Represent 2-3-4 tree as a BST. Use "internal" left-leaning edges for 3- and 4- nodes. 1-1 correspondence between 2-3-4 and left-leaning red-black trees. Insert implementation Complexity Libfdr Libfdr is a library which contains an implementation for generic red-black trees in C Download and compile instructions at http://www.cs.utk.edu/~plank/plank/classes/cs36 0/360/notes/Libfdr/ Jval datatype A big union to represent a generic data type typedef union { int i; long l; float f; double d; void *v; char *s; char c; unsigned char uc; short sh; unsigned short ush; unsigned int ui; int iarray[2]; float farray[2]; char carray[8]; unsigned char ucarray[8]; } Jval; Jval usage Use Jval to store an integer Jval j; j.i = 4; Jval.h defines a whole bunch of prototypes for ``constructor functions.'' extern Jval new_jval_i(int); extern new_jval_f(float); extern Jval Jval new_jval_d(double); extern Jval new_jval_v(void *); extern Jval new_jval_s(char *); Example: Jval j = new_jval_i(4); JRB datatype JRB is defined as a pointer to a node of the tree typedef struct jrb_node { unsigned char red; unsigned char internal; unsigned char left; unsigned char roothead; struct jrb_node *flink; struct jrb_node *blink; struct jrb_node *parent; Jval key; Jval val; } *JRB; JRB API (1) Make a new tree Insert a new node to a tree JRB make_jrb(); JRB jrb_insert_str(JRB tree, char *key, Jval val); JRB jrb_insert_int(JRB tree, int ikey, Jval val); JRB jrb_insert_dbl(JRB tree, double dkey, Jval val); JRB jrb_insert_gen(JRB tree, Jval key, Jval val, int (*func)(Jval,Jval)); Find a node via key JRB jrb_find_str(JRB root, char *key); JRB jrb_find_int(JRB root, int ikey); JRB jrb_find_dbl(JRB root, double dkey); JRB jrb_find_gen(JRB root, Jval, int (*func)(Jval, Jval)); JRB API (2) Free a node (but not the key or val) Free all the tree void jrb_delete_node(JRB node); void jrb_free_tree(JRB root); Navigation in the tree #define jrb_first(n) (n->flink) #define jrb_last(n) (n->blink) #define jrb_next(n) (n->flink) #define jrb_prev(n) (n->blink) #define jrb_empty(t) (t->flink == t) #define jrb_nil(t) (t) #define jrb_traverse(ptr, lst) \ for(ptr = jrb_first(lst); ptr != jrb_nil(lst); ptr = jrb_next(ptr)) Quiz 1 Try to compile and run some example programs (using libfdr) given at http://www.cs.utk.edu/~plank/plank/classes/cs36 0/360/notes/JRB/ Quiz 2 Use libfdr to write the phone book program (add, delete, modify phone numbers). The phone book should be stored in a file. NB: In the JRB, the insert function always creates a new node event the key exists already in the tree. You should check the existence of a record before insert it in the tree Instruction Create a phone book JRB book = make_jrb(); Insert a new entry jrb_insert_str(book, strdup(name), new_jval_l(number)); You must allocate memory to store the name for the new nodes key. This memory should to be free when we delete all the key. Navigation jrb_traverse(node, book) /* code to do something on node */ Solution phonebook_jrb.c
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Sakarya Üniversitesi - COMPUTER S - 320
2012 / 2013 AKADEMK YILI FARAB DEM PROGRAMI N YERLETRME SONULARI* Baar durumlar (akademik ort.) baz alnarak rencilerimiz tercihlerine gre en yksektenaa olacak ekilde niversitemizce yerletirmeleri gerekletirilen rencilerimiz tercihinizionaylayp onaylama
Australian National - FINM - 1001
cha1Student: _1.In 2007, _ was the most significant real asset of U.S. households in terms of total value.A. consumer durablesB. automobilesC. real estateD. mutual fund sharesE. bank loans2.In 2007, _ was the least significant financial asset of
Australian National - FINM - 1001
ch2Student: _1.Which of the following is not a characteristic of a money market instrument?A. liquidityB. marketabilityC. long maturityD. liquidity premiumE. C and D2.The money market is a subsector of theA. money market.B. capital market.C.
Australian National - FINM - 1001
ch3Student: _1.The trading of stock that was previously issued takes placeA. in the secondary market.B. in the primary market.C. usually with the assistance of an investment banker.D. A and B.E. B and C.2.A purchase of a new issue of stock takes
Australian National - FINM - 1001
ch4Student: _1.Which one of the following statements regarding open-end mutual funds is false?A. The funds redeem shares at net asset value.B. The funds offer investors professional management.C. The funds offer investors a guaranteed rate of return
Australian National - FINM - 1001
ch5Student: _1.Over the past year you earned a nominal rate of interest of 10 percent on your money. The inflation ratewas 5 percent over the same period. The exact actual growth rate of your purchasing power wasA. 15.5%.B. 10.0%.C. 5.0%.D. 4.8%.
Australian National - FINM - 1001
ch6Student: _1.Which of the following statements regarding risk-averse investors is true?A. They only care about the rate of return.B. They accept investments that are fair games.C. They only accept risky investments that offer risk premiums over th
Australian National - FINM - 1001
ch7Student: _1.Market risk is also referred to asA. systematic risk, diversifiable risk.B. systematic risk, nondiversifiable risk.C. unique risk, nondiversifiable risk.D. unique risk, diversifiable risk.E. none of the above.2.Systematic risk is
Australian National - FINM - 1001
ch8Student: _1.As diversification increases, the total variance of a portfolio approaches _.A. 0B. 1C. the variance of the market portfolioD. infinityE. none of the above2.As diversification increases, the standard deviation of a portfolio appro
Australian National - FINM - 1001
ch9Student: _1.In the context of the Capital Asset Pricing Model (CAPM) the relevant measure of risk isA. unique risk.B. beta.C. standard deviation of returns.D. variance of returns.E. none of the above.2.In the context of the Capital Asset Pric
Australian National - FINM - 1001
ch13Student: _1.The expected return/beta relationship is used _.A. by regulatory commissions in determining the costs of capital for regulated firmsB. in court rulings to determine discount rates to evaluate claims of lost future incomesC. to advise
Australian National - FINM - 1001
ch14Student: _1.The current yield on a bond is equal to _.A. annual interest divided by the current market priceB. the yield to maturityC. annual interest divided by the par valueD. the internal rate of returnE. none of the above2.If a 7% coupon
Australian National - FINM - 1001
ch15Student: _1.The term structure of interest rates is:A. The relationship between the rates of interest on all securities.B. The relationship between the interest rate on a security and its time to maturity.C. The relationship between the yield on
Australian National - FINM - 1001
ch16Student: _1.The duration of a bond is a function of the bond'sA. coupon rate.B. yield to maturity.C. time to maturity.D. all of the above.E. none of the above.2.Ceteris paribus, the duration of a bond is positively correlated with the bond's
Australian National - FINM - 1001
ch17Student: _1.A top down analysis of a firm starts with _.A. the relative value of the firmB. the absolute value of the firmC. the domestic economyD. the global economyE. the industry outlook2.An example of a highly cyclical industry is _.A.
Australian National - FINM - 1001
ch18Student: _1._ is equal to the total market value of the firm's common stock divided by (the replacement cost ofthe firm's assets less liabilities).A. Book value per shareB. Liquidation value per shareC. Market value per shareD. Tobin's QE. No
Australian National - FINM - 1001
ch19Student: _1.A firm has a higher quick (or acid test) ratio than the industry average, which implies.A. the firm has a higher P/E ratio than other firms in the industry.B. the firm is more likely to avoid insolvency in short run than other firms i
Australian National - FINM - 1001
ch20Student: _1.The price that the buyer of a call option pays to acquire the option is called theA. strike priceB. exercise priceC. execution priceD. acquisition priceE. premium2.The price that the writer of a call option receives to sell the o
Australian National - FINM - 1001
ch21Student: _1.Before expiration, the time value of an in the money call option is alwaysA. equal to zero.B. positive.C. negative.D. equal to the stock price minus the exercise price.E. none of the above.2.Before expiration, the time value of a
Australian National - FINM - 1001
ch22Student: _1.A futures contractA. is an agreement to buy or sell a specified amount of an asset at the spot price on the expiration date ofthe contract.B. is an agreement to buy or sell a specified amount of an asset at a predetermined price on t
Australian National - FINM - 1001
ch23Student: _1.Which one of the following stock index futures has a multiplier of $250 times the index value?A. Russell 2000B. S&P 500 IndexC. NikkeiD. DAX-30E. NASDAQ 1002.Which one of the following stock index futures has a multiplier of $10
Australian National - FINM - 1001
ch24Student: _1.Trading activity by mutual funds just prior to quarterly reporting dates is known asA. insider trading.B. program trading.C. passive security selection.D. window dressing.E. none of the above.2.Window dressing isA. also known as
Australian National - FINM - 1001
ch25Student: _1.Shares of several foreign firms are traded in the U.S. markets in the form ofA. ADRsB. ECUsC. single-country fundsD. all of the aboveE. none of the above2._ refers to the possibility of expropriation of assets, changes in tax pol
Australian National - FINM - 1001
ch26Student: _1._ are the dominant form of investing in securities markets for most individuals and _ haveenjoyed far greater growth rate in the last decade.A. Hedge funds; hedge fundsB. Mutual funds; hedge fundsC. Hedge funds; mutual fundsD. Mutu
Australian National - FINM - 1001
ch27Student: _1.In the Treynor-Black modelA.portfolio weight are sensitive to large alpha values which can lead to infeasible long or short position formany portfolio managers.B portfolio weight are not sensitive to large alpha values which can lead
Australian National - FINM - 1001
ch28Student: _1.The CFA Institute divides the process of portfolio management into 3 main elements, which are _,_, and _.A. planning; execution; resultsB. security selection; asset allocation; actionC. planning; asset allocation; feedbackD. planni
Australian National - FINM - 1001
cha10Student: _1._ a relationship between expected return and risk.A. APT stipulatesB. CAPM stipulatesC. Both CAPM and APT stipulateD. Neither CAPM nor APT stipulateE. No pricing model has found2._ a relationship between expected return and risk
Australian National - FINM - 1001
cha11Student: _1.If you believe in the _ form of the EMH, you believe that stock prices reflect all relevantinformation including historical stock prices and current public information about the firm, but notinformation that is available only to insi
Australian National - FINM - 1001
cha12Student: _1.Conventional theories presume that investors _ and behavioral finance presumes that they_.A. are irrational; are irrationalB. are rational; may not be rationalC. are rational; are rationalD. may not be rational; may not be rationa
Australian National - FINM - 1001
MKTG2203 Quiz 130 Multiple Choice Questions circle the letter of your answer1. Marketing involvesa. a mutual exchange of value between a customer and an organisation.b. creating, communicating and delivering a good, service or idea.c. individuals and
Australian National - FINM - 1001
`2MKTG2203 Quiz 230 Multiple Choice Questions circle the letter of your selected answer1. The four major types of business markets area. Producer markets, consumer markets, government markets, institutional marketsb. Producer markets, government marke
Australian National - FINM - 1001
Student number (only)/ 30TOTALMKTG2203 Quiz 330 Multiple Choice Questions circle the letter of your selected answer1. Which of the following statements is incorrect?a. An exchange of value always involves a monetary transaction.b. Price is a measur
Australian National - FINM - 1001
MKTG2203 Quiz 430 Multiple Choice Questions circle the letter of your selected answer1. Service industries generate about _ per cent of the national incomes ofAustralia and New Zealand.a. twentyb. seventyc. fiftyd. ninetye. ten2. Which of the fol
Australian National - FINM - 1001
Error: Reference source not foundUWA Business School/MarketingSUMMER SCHOOL 2012MOCK EXAMINATIONMKTG2203Marketing ManagementFAMILY NAME:_ GIVEN NAMES: _STUDENT ID:SIGNATURE: _This Paper Contains: 7 pages (including title page)Time allowed: 45 mi
Australian National - FINM - 1001
Writing Task 1PersonalSemi- FormalFormalFormalTosomeoneyou DearSir/havenotmet,Madamwhosenameyoudon'tknowYoursfaithfullySemiformalTosomeoneyou DearMrBrown,mayormaynot DearMsStonehavemet,whoselastnameyouknow&useYourssincerelyInformalToso
Keller Graduate School of Management - ACCOUNTING - AC555
Shari AckonAuditing Week 5 HW12-17a.(1) b.(1) c.(3) d.(3)12-18a.(1) b.(3) c.(2) d.(3)12-27Some recommendations to improve Hardwoods information systemsfunction Is to first to develop a backup and contingency plan for software.Newt would b
Emerson - MARKETING - 649
E01006574 Rebecca ShyuCase Analysis: Culinarian Cookware: Pondering Price PromotionIn order to decide if Culinarian Cookware should keep offering price discountson its products, the company needs to solve two primary issues. Firstly, its necessaryfor
University of Iowa - 004 - 011
BLBM Chapter 20:ELECTROCHEMISTRYIntroduction, Electrical definitionsRedox reactions and their balancingVoltaic cellsCell potentialsFree energy & electrical workBatteries & fuel cellsCorrosionElectrolytic cellsELECTROCHEMISTRY IS EVERYWHEREalkal
University of Iowa - 004 - 011
Chemistry 4:12 HandoutSunday, March 20, 2011BLBM Chapter 22:CHEMISTRY OF THE NONMETALSHydrogenGroup 8A (18):7A (17):6A (16):5A (15):4A (14):3A (13):Helium family (noble gases)Fluorine family (halogens)Oxygen family (chalcogens)Nitrogen famil
University of Iowa - 004 - 011
Chemistry 4:12 HandoutMonday, March 28, 2011BLBM Chapter 24:CHEMISTRY OFCOORDINATION COMPOUNDSOverview of transition metal propertiesCoordination complexesCoordination geometriesColors, absorption spectroscopy,electronic transitionsMagnetismCry
University of Iowa - 004 - 011
Chemistry 4:12 HandoutSunday, May 1, 2011METALLIC BONDINGMetals have distinctive properties:lustermalleability (hammer into thin sheets)ductility (draw into wires)electrical conductivitythermal conductivity(usually parallels electrical conductivi
University of Iowa - 004 - 011
Chemistry 4:12 HandoutTuesday, April 26, 2011BLBM Chapter 23:METALS AND METALLURGYElement sourcesExtractive metallurgyPyrometalurgyHydrometallurgyElectrometallurgyIron, steel, sodium, aluminumPurification of metalsAlloysSOURCES OF THE ELEMENTS
University of Iowa - 004 - 011
Chemistry 4:12 HandoutTuesday, February 1, 2011BLBM Chapter 21:NUCLEAR CHEMISTRYChemical vs. nuclear reactionsNuclear medicineRadioactivity a nd balancing nuclear reactionsNuclear stability and transmutationHalf-lives and rates of radioactive deca
University of Iowa - 004 - 011
Chemistry 4:12 HandoutSaturday, February 5, 2011BLBM Chapter 25:THE CHEMISTRY OF LIFE:ORGANIC AND BIOLOGICALCHEMISTRYOverview of hybridization, bondingHydrocarbons and isomerismDrawing and naming organic compoundsFunctional groupsChirality / opt
University of Iowa - 004 - 011
Chemistry 4:12 HandoutSaturday, February 5, 2011CARBONYL COMPOUNDS: Two groupsaldehydes, ketones have C or H (dont attract electronsAldehydes, ketonesstrongly) bound to carbonyl C .Atoms O, X (halogen), or N (more electronegative than C)bound to ca
University of Iowa - 004 - 011
Chapter 13Properties of Solutions13.1 The Solution Process13.2 Saturated Solutions & Solubility13.3 Factors Affecting Solubility13.4 Ways of Expressing Concentration13.5 Colligative Properties13.6 ColloidsRead Ch. 13 in BLBMCh. 13 Mastering Chemi
University of Iowa - 004 - 011
Chapter 17Additional Aspects of Aqueous Equilibria17.1 Common Ion Effect17.2 Buffered Solutions17.3 Acid-Base Titrations17.4 Solubility Equilibria17.5 Factors That Affect Solubility17.6 Precipitation and Separation of Ions17.7 Qualitative Analysis
University of Iowa - 004 - 011
!"#"$%Chapter 18 Chemistry of the Environment!18.1 Earths Atmosphere18.2 Outer Regions of the Atmosphere18.3 Ozone in the Upper Atmosphere18.4 Chemistry of the Troposphere18.5 The World Ocean18.6 Freshwater18.7 Green Chemistry$%18.1 Earths Atmos
University of Iowa - 004 - 011
Ch. 19 Chemical Thermodynamics19.1 Spontaneous Processes19.2 Entropy and the 2nd Law19.3 The Molecular Interpretation of Entropy19.4 Entropy Changes in Chemical Reactions19.5 Gibbs Free Energy19.6 Free Energy and Temperature19.7 Free Energy and the
University of Iowa - 004 - 011
Chapter 14 Chemical Kinetics14.1 Factors That Affect Reaction Rates14.2 Reaction Rates14.3 Concentration and Rate14.4 Change of Concentration with Time14.5 Temperature and Rate14.6 Reaction Mechanisms14.7 Catalysis1Assignment/ Study Suggestions
University of Iowa - 004 - 011
Chapter 16Acid-Base EquilibriaAcids and Bases16.1 Acids and Bases: A Brief Review16.2 Brnsted-Lowry A cids and Bases16.3 The A utoionization of Water16.4 The pH Scale16.5 Strong Acids and Bases16.6 Weak Acids16.7 Weak Bases16.8 Relationship betw
University of Iowa - 004 - 011
Unit 8: KineticsCHEM 4:012Unit 8 Case StudyChemical Kinetics andCatalysisThinking about ChemistryCentral Theme in Chemistry: Macroscopic propertiesand behaviors are the results submicroscopic propertiesand behaviors.Aphorism III: where the cause
University of Iowa - 004 - 123
A chemistry timeline3000 900 BC: Metallurgy and fermentation300 BC 1600 AD: Rise and fall of alchemy1605: Forerunner of modern scientific method articulated by Francis Bacon1600s: Development of atomistic theory of matter (Robert Boyle)1667: Becher p
University of Iowa - 004 - 123
Chapter 2Polar Covalent Bonds: Acids andBases(Learning this material now will help you later!)1Why this chapter? Description of basic ways chemistsaccount for chemical reactivity. Establish foundation for understandingspecific reactions discussed
University of Iowa - 004 - 123
Chapter 3Organic Compounds: Alkanesand Their Stereochemistry(Discussions of real organic molecules!)Why this Chapter? Alkanes will be used to discuss basic approaches tonaming organic compounds We will take an initial look at 3-D aspects ofmolecul
University of Iowa - 004 - 123
Chapter 9Stereochemistry(We live in a chiral world)Why this Chapter? Stereochemistry concerns the three dimensionalstructure of molecules Compounds that are identical except for the orientationof atoms in three dimensions are stereoisomers The ste
University of Iowa - 004 - 123
Chapter 5An Overview of OrganicReactions(We will return to these concepts throughout this semester and the next)1Why this chapter?Fundamental discussion concerning thewhy and how of all organic reactions21 Kinds of Organic ReactionsFour basic ty
University of Iowa - 004 - 123
Chapter 10Organohalides(Really a warm-up act for the main event that is Chapter 11)Why this Chapter? Organohalides undergo many important reactions suchas nucleophilic substitution and elimination Alkyl halide chemistry can serve as a model formech
University of Iowa - 004 - 123
Chapter 11Reactions of Alkyl Halides:Nucleophilic Substitutions andEliminations(These are fundamentally important reactions in organic chemistry)Why this Chapter? Nucleophilic substitution and base inducedelimination are among most widelyoccurring
University of Iowa - 004 - 123
Chapter 12Structure Determination: MassSpectrometry and Infrared SpectroscopyWhy this Chapter? We have to have ways for determining thestructure of organic molecules in order toidentify natural products and to identifycompounds produced by synthesi
University of Iowa - 004 - 123
Chapter 13Structure Determination: NuclearMagnetic Resonance Spectroscopy(The most important spectroscopic technique in organic chemistry)Why This Chapter? NMR is the most valuable spectroscopic technique usedfor structure determination More advanc