Lecture%2009%20-%20Structs%20and%20Linked%20Lists
11 Pages

Lecture%2009%20-%20Structs%20and%20Linked%20Lists

Course Number: CS 123, Fall 2007

College/University: Carnegie Mellon

Word Count: 2604

Rating:

Document Preview

Lecture 09 C Structs and Linked Lists In this lecture Structs in C operator Structs within BMP files Reading Header information from BMP files Passing structs to functions Passing pointer to structs Array of structs and Array of struct pointers Concept of a linked list Types of Linked List Implementation Further readings Exercises Answers Structs in C Structs in C are used to package several data...

Unformatted Document Excerpt
Coursehero >> Pennsylvania >> Carnegie Mellon >> CS 123

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.

09 Lecture C Structs and Linked Lists In this lecture Structs in C operator Structs within BMP files Reading Header information from BMP files Passing structs to functions Passing pointer to structs Array of structs and Array of struct pointers Concept of a linked list Types of Linked List Implementation Further readings Exercises Answers Structs in C Structs in C are used to package several data fields into one unit. Structs can be used to define types and can be used to define variables of that type. C structs are different from Java classes. Java Classes encapsulates both state (data fields) and behavior (methods) with these fields being public, private or protected. C structs can only declare public data fields and all fields are accessible using the dot (.) operator. For example, if we define a typedef for a struct that contain two fields, var1 and var2 as: typedef struct { unsigned int var1; char* var2; } node; and a variable mynode of type node node mynode; fields within mynode variable can be accessed using, mynode.var1 = 100; mynode.var2 = malloc(20); =================== (1) Copyright @ 2009 Ananda Gunawardena The amount of memory required to hold the variable mynode is equivalent to sizeof(unsigned int) + sizeof(char*) . You can also write sizeof(node) to find the how many bytes are required to hold a variable of size node. Note that sizes of specific data types are dependent on the machine you may be using. For example, on andrew domain machines(unix.andrew.cmu.edu), an address variable is 4 bytes while in CS domain machines (linux.gp.cs.cmu.edu) an address variable is 8 bytes. As with initializing variables as they are declared, structs can also be initialized as node mynode = {100, malloc(20)}; operator There are two ways to access fields within a struct. Field within a struct can be accessed using the dot operator. However, if a pointer to the struct is given, then we can access fields within the struct using -> operator. For example, node mynode; node* ptr = &mynode; ptr var1 = 100; ptr var2 = malloc(20); is equivalent to the code given above in (1) using the dot operator. The arrow operator will be used extensively in cases where a pointer to the struct is passed to a function instead of a copy. Structs within BMP files An interesting example of a struct type is header information stored in a bitmap (BMP) file. BMP, a format invented by Microsoft stores the image using a schema as follows. The first 14 bytes is reserved for information given by the following struct typedef struct { unsigned short int type; /* BMP type identifier */ unsigned int size; /* size of the file in bytes*/ unsigned short int reserved1, reserved2; unsigned int offset; /* starting address of the byte */ } HEADER; The next 40 bytes are reserved for a structure as follows. typedef struct { unsigned int size; /* Header size in bytes */ int width,height; /* Width and height in pixels */ unsigned short int planes; /* Number of color planes */ unsigned short int bits; /* Bits per pixel */ unsigned int compression; /* Compression type */ unsigned int imagesize; /* Image size in bytes */ int xresolution,yresolution; /* Pixels per meter */ unsigned int ncolors; /* Number of colors */ Copyright @ 2009 Ananda Gunawardena unsigned int importantcolors; } INFOHEADER; /* Important colors */ Suppose we are interested in extracting this information from a BMP file. First we need to read a block of 54 bytes using fread function as follows. Since BMP files are binary files (recall that there are two types of files, ASCII and Binary) and reading bytes from a BMP file needs to be done using fread (instead of fscanf for formatted data) The prototype of the fread function is given by #include <stdio.h> size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); The fread() function reads, into the array pointed to by ptr, up to nitems members whose size is specified by size in bytes, from the stream pointed to by stream. [source:open group] Reading Header Information from BMP file Suppose we would like to read header information from a BMP file. Let us first allocate a block of 54 bytes to hold the struct. void* ptr = malloc(54); Now we can read 54 bytes from a file stream that is opened. FILE* infile = fopen(image.bmp, r); fread(ptr, 54, 1, infile); Now suppose we need to find the width and height of the image from header information. We could look at the 54 bytes as follows. To find the width, we need to offset a total of 18 bytes (14 + 4 bytes for the unsigned int). Hence we can extract information about width as follows. int* tmp = ptr + 18; printf(The width of the image is %d \n, *tmp); Similarly all other information about the BMP file can be extracted and manipulated. Copyright @ 2009 Ananda Gunawardena Passing Structures to Functions Structures can be passed to functions as arguments. For example, consider the following function foo that takes a copy of a struct as an argument. We will be using struct INFOHEADER as defined above in BMP example. int foo(INFOHEADER info){ .. return 0; } We define a variable info and pass that to function foo. A copy of info is made and placed on the runtime stack of foo. INFOHEADER info; foo(info); Note that the fields within the original variable info may not be affected by statements in foo. When a structure is passed as value parameter, a copy of the struct is made on the runtime stack and information is used to perform the operations. If the function does not require permission to change the original variable info, this may be ok. However, a programmer needs to be aware that if the struct is large, then two much information may be copied to run time stack, making the program run slower. A programmer must be careful in a situation where the foo may be called multiple times. Passing a Pointer to a Struct To avoid copying large structs within the run time stack, we can pass the address of a struct variable (i.e. a pointer) to a function. There are two instances under which passing a pointer to a struct, instead of a copy of the struct may be advantages. A pointer allows efficient access to the struct (instead of making a copy on runtime stack) as well as the opportunity to directly manipulate the information within the original struct. For example, if we need to change some information within a field of INFOHEADER, we can pass the address of an INFOHEADER variable to a function whose prototype is given by int foo(INFOHEADER* ptr){ .. ptr width = 720; return 0; } In the calling function we can do; Copyright @ 2009 Ananda Gunawardena INFOHEADER info; foo(&info); Now the fields within the original variable info can be manipulated directly by the ptr. ptr -> width = 720; Compromising Security One disadvantage of passing an address to a function is that we may be compromising the security of the variable. When a pointer to a struct is passed to a function, then the function can change the information within the struct, even if you did not intend to do so. But there is a way to retain the efficiency of passing by reference, while maintaining the security. One possibility is to define a function as follows. int foo(const INFOHEADER* ptr){ .. return 0; } This does not allow any changes to the original content, but provides access to the fields within the struct directly from the ptr. So ptr -> width = 100; would be illegal while int tmp = ptr -> width; would be legal Array of Structs Structs can be combined to form an array. Suppose we need to define a struct that will store positional information as well as color information of a point in 2D space. A struct 2Dpoint is then can be defined as follows. typedef struct { unsigned char R,G,B; // stores a value between representing 0-255 the color depth int x,y; } 2Dpoint; Then we can define an array of 100, 2D points as follows. 2Dpoint A[100]; Copyright @ 2009 Ananda Gunawardena The array can also be initialized as 2Dpoint A[100] = {{0,0,255,20,40}, {255,0,255,40,20}, .}; It should be noted that one could ignore the inner braces as long as the list matches the amount and type of things to be initialized. So we could write 2Dpoint A[100] = {0,0,255,20,40,255,0,255,40,20, .}; Array of Struct Pointers In some applications, using an array of struct pointers may be useful. Therefore we can define an array of struct points as follows. 2Dpoint* A[100]; In this case each array element, A[i], is a pointer to a 2Dpoint. Access to the fields can be obtained using A[i] R = 255; /* changes the color red to 255 */ Dynamically Allocated Lists Concept of a linked list Static arrays are structures whose size is fixed at compile time and therefore cannot be extended or reduced to fit the data set. A dynamic array can be extended by doubling the size but there is overhead associated with the operation of copying old data and freeing the memory associated with the old data structure. One potential problem of using arrays for storing data is that arrays require a contiguous block of memory which may not be available, if the requested contiguous block is too large. However the advantages of using arrays are that each element in the array can be accessed very efficiently using an index. However, for applications that can be better managed without using contiguous memory we define a concept called linked lists. A linked list is a collection of objects linked together by references from one object to another object. By convention these objects are named as nodes. So the basic linked list is collection of nodes where each node contains one or more data fields AND a reference to the next node. The last node points to a NULL reference to indicate the end of the list. Copyright @ 2009 Ananda Gunawardena image source: Weiss Data Structures The entry point into a linked list is always the first or head of the list. It should be noted that head is NOT a separate node, but a reference to the first Node in the list. If the list is empty, then the head has the value NULL. Unlike Arrays, nodes cannot be accessed by an index since memory allocated for each individual node may not be contiguous. We must begin from the head of the list and traverse the list sequentially to access the nodes in the list. Insertions of new nodes and deletion of existing nodes are fairly easy to handle and will be discussed in the next lesson. Recall that array insertions or deletions may require adjustment of the array (overhead), but insertions and deletions in linked lists can be performed very efficiently. Types of Linked Lists There are few different types of linked lists. A singly linked list as described above provides access to the list from the head node. Traversal is allowed only one way and there is no going back. A doubly linked list is a list that has two references, one to the next node and another to previous node. Doubly linked list also starts from head node, but provide access both ways. That is one can traverse forward or backward from any node. A multilinked list (see figures 1 & 2) is a more general linked list with multiple links from nodes. For examples, we can define a Node that has two references, age pointer and a name pointer. With this structure it is possible to maintain a single list, where if we follow the name pointer we can traverse the list in alphabetical order of names and if we traverse the age pointer, we can traverse the list sorted by ages. This type of node organization may be useful for maintaining a customer list in a bank where same list can be traversed in any order (name, age, or any other criteria) based on the need. Copyright @ 2009 Ananda Gunawardena Figure 1 Linked List with two pointers Another example of multilinked list is a structure that represents a sparse matrix as shown below. Figure 2 A sparse matrix representation Another important type of a linked list is called a circular linked list where last node of the list points back to the first node (or the head) of the list. Copyright @ 2009 Ananda Gunawardena Implementation of a Linked List Designing the Node Linked list is a collection of linked nodes. A node is a struct with at least a data field and a reference to a node of the same type. A node is called a self-referential object, since it contains a pointer to a variable that refers to a variable of the same type. For example, a struct Node that contains an int data field and a pointer to another node can be defined as follows. struct Node { int data; struct Node* next; } typedef struct Node node; node* head = NULL; Allocating memory for the first node Memory must be allocated for one node and assigned to head as follows. head = (node*) malloc(sizeof(node)); (*head).data = 10; (*head).next = NULL; head 10 Adding the second node and linking node* nextnode = malloc(sizeof(node)); (*nextnode).data = 12; (*nextnode).next = NULL; (*head).next = nextnode; head 10 12 Continuation of this process creates a linked list of nodes. The advantages of a linked list as compared to an array is that memory blocks are small and hence there is Copyright @ 2009 Ananda Gunawardena more flexibility in managing memory required by the application. In the next lesson we will discuss some operations on linked lists as well as details about implementing a Doubly Linked List. Further Readings [1] K & R chapter 6.1-6.4 pages 127-138 [2] http://www.cs.cmu.edu/~thoffman/S09-15123/Chapter-4/Chapter4.html#CHAP_4.1 Exercises For all of the following exercises (where applicable) use the following definition of node. typedef struct node { int data; struct node* next; } node; [1] What would be returned if sizeof(node) is used (assume linux.andrew.cmu.edu) [2] What is wrong with the following code? node ptr; ptr data = 25; ptr next = NULL; [3] The following code is supposed to insert a new node, after the first node. (assume there is at least one node). However, the code seems to throw a seg fault after sometime. What could be the reason? node* newnode = malloc(sizeof(node)); first next = newnode; newnode next = first next; [4] design a struct that can be used to implement a multilinked list as given in Figure 2. Include the proper fields to hold all the data. Copyright @ 2009 Ananda Gunawardena Answers For all of the following exercises (where applicable) use the following definition of node. typedef struct node { int data; struct node* next; } node; [1] What would be returned if sizeof(node) is used (assume linux.andrew.cmu.edu) ANSWER: sizof(node) = sizeof(int) + sizeof(struct node*) = 4 +4 =8 [2] What is wrong with the following code? node ptr; ptr data = 25; ptr next = NULL; ANSWER: Memory is not being allocated for ptr. Therefore any dereference to Ptr data could cause a segmentation fault [3] The following code is supposed to insert a new node, after the first node. (assume there is at least one node). However, the code seems to throw a seg fault after sometime. What could be the reason? node* newnode = malloc(sizeof(node)); first next = newnode; ----------------- (2) ----------------- (3) newnode next = first next; ANSWER: The problem seems to be that this creates an infinite loop situation. We can fix the code by switching lines 2 and 3. [4] design a struct that can be used to implement a multilinked list as given in Figure 2. Include the proper fields to hold all the data. ANSWER: typedef struct node { int row, col; double value; struct node* rowptr; struct node* colptr; } node; Copyright @ 2009 Ananda Gunawardena

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:

Carnegie Mellon - CS - 123
Lecture 10 Linked List OperationsIn this lecture Concept of a linked list revisited Types of Linked Lists Designing a node of a Linked List Operations on Linked Lists o Appending a node to a Linked List o Prepending a node to a linked list o Inserting a
Carnegie Mellon - CS - 123
Lecture 11 Array of Linked ListsIn this lecture Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for Sparse Matrix Exercises SolutionsAn Array of Linked ListsA linked list is defined as a collection o
Carnegie Mellon - CS - 123
Lecture 12 Doubly Linked Lists (with Recursion)In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively) o Printing a LL (recursively) o Appending a
Carnegie Mellon - CS - 123
Lecture 13 Function Pointers In this lecture Functions with variable number of arguments Introduction to function pointers Example of passing a function pointer to a function (qsort) Defining a function pointer Generic Data Types Functions with variable n
Carnegie Mellon - CS - 123
Lecture 14 Generic Data Structures In this lecture Introduction to Generic Data structures Examples An Introduction to Generic Data StructuresPrograms use many different data structures such as arrays, linked lists, hash tables, general trees, binary sea
Carnegie Mellon - CS - 123
Lecture 15 Introduction to HashingWhy Hashing? Internet has grown to millions of users generating terabytes of content every day. According to internet data tracking services, the amount of content on the internet doubles every six months. With this kind
Carnegie Mellon - CS - 123
Lecture 16More on HashingCollision ResolutionIntroduction In this lesson we will discuss several collision resolution strategies. The key thing in hashing is to find an easy to compute hash function. However, collisions cannot be avoided. Here we discu
Carnegie Mellon - CS - 123
Lecture 17 Bit OperationsIn this lecture Background Left Shifting Negative Numbers, complement Right Shifting Bit Operators Masking the Bits Getting the Bits Setting the Bits Binary Files Bit fields More ExercisesonescomplementandtwosC is a powerful
Carnegie Mellon - CS - 123
Lecture 18 Regular ExpressionsMany of todays web applications require matching patterns in a text document to look for specific information. A good example is parsing a html file to extract &lt;img&gt; tags of a web document. If the image locations are availab
Carnegie Mellon - CS - 123
Lecture 19 Perl ProgrammingPerl (Practical Extraction and Report Language) is a powerful and adaptable scripting language. Perl became very popular in early 90s as web became a reality. Perl is ideal for processing text files containing strings. Perl is
Carnegie Mellon - CS - 123
Lecture 20 Advanced Perl ProgrammingIn the previous lecture, we learned some basic constructs of perl programming including regex processing in Perl. Combining regex constructs with other high level programming capabilities of Perl is one of the main adv
Carnegie Mellon - CS - 123
Lecture 21 Systems Programming in CA C program can invoke UNIX system calls directly. A system call can be defined as a request to the operating system to do something on behalf of the program. During the execution of a system call, the mode is change fr
Carnegie Mellon - CS - 123
Lecture 22 Systems Programming Process ControlA process is defined as an instance of a program that is currently running. A uni processor system can still execute multiple processes giving the appearance of a multiprocessor machine. A call to a program s
Carnegie Mellon - CS - 123
Ananda GunawardenaLecture 23 Assembler FundamentalsAll programs written in a high-level language like C are converted into machine language so they can be executed by the underlying hardware. However, the process of converting high level source code to
Carnegie Mellon - CS - 123
Ananda GunawardenaLecture 31 C and AssemblyHigh level languages are designed to allow programmers to write programs in a way that is closer to the logical thinking of the program flow. However, programming in assembly language requires programmers to un
Carnegie Mellon - CS - 123
Ananda GunawardenaLecture 25 Course ReviewFinal Exam is given during 5 reserved time slots in wean 5419.05-04 05-06 05-08 05-12 MON WED THU TUE 1:00pm-4:00pm 1:00pm-4:00pm 1:00pm-4:00pm 1:00pm-4:00pm (Hub Schedule time)You need to signup for one of th
Carnegie Mellon - CS - 123
Ananda GunawardenaLecture 26 Course Review IIPerl Programming Basics This is only a partial list of tasks that you should know. Anything else can be found by using the man pages &gt; man perl and use the specific pages to find information. For example, &gt;ma
Carnegie Mellon - CS - 123
import java.io.*; import java.util.*; public class javasort cfw_ public static void main(String[] args) throws Exception cfw_ long begin, end; begin = System.currentTimeMillis(); int n = Integer.parseInt(args[0]); int[] A = new int[n]; Random R = new Rand
UCSB - PHYS - PHYS 4
Page 1 of 14mhtml:file:/C:\Documents and Settings\easyPDFUser\Local Settings\Temp\BCL Technol.4/15/2009Page 2 of 14mhtml:file:/C:\Documents and Settings\easyPDFUser\Local Settings\Temp\BCL Technol.4/15/2009Page 3 of 14mhtml:file:/C:\Documents and S
UCSB - PHYS - PHYS 4
UCSB - PHYS - PHYS 4
Page 1 of 16mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.1/15/2009Page 2 of 16mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.1/15/2009Page 3 of 16mhtml:file:/C:\Documents%20and%20Setti
UCSB - PHYS - PHYS 4
Page 1 of 14mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.1/28/2009Page 2 of 14mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.1/28/2009Page 3 of 14mhtml:file:/C:\Documents%20and%20Setti
UCSB - PHYS - PHYS 4
UCSB - PHYS - PHYS 4
Page 1 of 23mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.2/10/2009Page 2 of 23mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.2/10/2009Page 3 of 23mhtml:file:/C:\Documents%20and%20Setti
UCSB - PHYS - PHYS 4
Page 1 of 10mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.2/20/2009Page 2 of 10mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\B.2/20/2009Page 3 of 10mhtml:file:/C:\Documents%20and%20Setti
UCSB - PHYS - PHYS 4
UCSB - PHYS - PHYS 4
Page 1 of 4mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\BC. 3/4/2009Page 2 of 4mhtml:file:/C:\Documents%20and%20Settings\easyPDFUser\Local%20Settings\Temp\BC. 3/4/2009Page 3 of 4mhtml:file:/C:\Documents%20and%20Settings
UCSB - PHYS - PHYS 4
UCSB - PHYS - PHYS 4
UCSB - PHYS - PHYS 2
Physics 2 Summer Session 2008 Quiz # 1Question 1 Let A = 4i + 6j and B = 2i + k. C = A x B is given by (a) (b) (c) (d) (e) 8i 6i 4j 12k 6i + 6j + k 6i + 4j + 12k none of the above(4i + 6j) x (2i + k) = 8 (i x i) + 4 (i x k) + 12 (j x i) + 6 (j x k) = 8
UCSB - PHYS - PHYS 2
Physics 2 Summer Session 2008 Quiz # 3 SolutionsQuestion 1 The path of each planet about the sun is an ellipse with the sun at (a) (b) (c) (d) the center one focus centered between the two foci on the apexCorrect answer is (b) Question 2 In the Simple H
UCSB - PHYS - PHYS 2
Physics 2 Summer Session 2008 Quiz # 4Question 1 Object A has twice the density and half the mass of object B. The ratio of the volume of A to the volume of B is (a) (b) 1 (c) Mass = Density x Volume Volume = Mass/Density. (d) 2 (e) 4Correct answer is (
UCSB - PHYS - PHYS 2
Physics 2 Summer Session 2008 Quiz # 5Question 1 Consider four objects A, B, C, and D. It is found that A and B are in thermal equilibrium. It is also found that C and D are in thermal equilibrium. However, A and C are not in thermal equilibrium. One can
UCSB - PHYS - PHYS 2
Physics 2 Summer 2008 FinalEnter solutions to the two problems in the blue book. Each problem is worth 15 points. (2 x 15 = 30). Enter answers to the 14 multiple choice questions in the scantron. The multiple choice questions are worth 70 points, total (
UCSB - PHYS - PHYS 2
UCSB - PHYS - PHYS 2
Physics 2 Summer 2008 MidtermEnter solutions to the two problems in the blue book. Each problem is worth 20 points. (2 x 20 = 40). Enter answers to the 15 multiple choice questions in the scantron. The multiple choice questions are worth 60 points, total
UCSB - PHYS - PHYS 2
Physics 2 MidtermDo not turn this page until you are instructed to do soPhysics 2 Spring 2009 Midterm Test Form AEnter solutions in the scantron. There is no penalty for wrong answers. Make sure to enter the test form in your scantronQuestion 1 Imagin
UCSB - PHYS - PHYS 2
UCSB - PHYS - PHYS 2
Cornell - BIOEE - 2780
Evolutionary Biology: Section Assignment Visit the Museum of the EarthVisit the Museum of the Earth and complete this worksheet You may visit the museum at your convenience between September 19th 27th This assignment is due in section during the week of
Cornell - BIOEE - 2780
11.Thecriticalmissingcomponentofthisstudyisaconsiderationofthehistorical(= evolutionary;phylogenetic)similaritiesamongthesebirdspecies,andtheuseof comparativeanalysis(=phylogenetic)methodstotakethoserelationshipsintoaccount whentestingforarelationshipb
Cornell - BIOEE - 2780
1. WhichofthefollowingstatementsisTRUE: Microevolutionarychangealwaysrequiresgeneticvariationtobepresentinapopulation. 2. Imaginethatyoucreatearandomlymating,infinitelysized,sexual,diploidpopulationwhere 80%ofthefoundingindividualsareAAand20%areAa.Afterth
Cornell - BIOEE - 2780
POPULATION GENETICS - PRACTICE PROBLEMS KEYFALL 2009These problems are designed to help you understand the concepts covered in lecture and section. However, merely completing this set of practice problems is not sucient preparation for the exam be sure
Cornell - BIOEE - 2780
POPULATION GENETICS - PRACTICE PROBLEMSFALL 2009These problems are designed to help you understand the concepts covered in lecture and section. However, merely completing this set of practice problems is not sucient preparation for the exam be sure to r
Cornell - BIOEE - 2780
10/29/09Ifs=selectiveadvantageoftheA1A1genotype&amp;d=thedominanceofthatadvantage fitness(A1A1)=w11=1+s fitness(A1A2)=w12=1+ds fitness(A2A2)=w22=1A1 dominant &amp; advantageousFitness FitnessA1 co-dominant &amp; advantageous FitnessA1 recessive &amp; advantageousA
Cornell - BIOEE - 2780
Cornell - BIOEE - 2780
For grading use only BioEE 2780_ mc_ 11_ 12_ 13_ 14exam total: _ /100 pts possibleYOUR NAME _PLEASE PRINT CLEARLYMidterm I October 7, 2008INSTRUCTIONS Do not open the exam until you are told to do so. Be sure to print your name on this page and
Cornell - BIOEE - 2780
1. Cyanobacteria had a notable influence on their environment because: a) they were able to use H2S from thermal vents to produce energy b) they had the metabolic capacity to consume oxygen from a super-saturated atmosphere c) they developed a photosystem
Cornell - BIOEE - 2780
1. (T/F) Since choroplasts are descendants of ancient prokaryotes, they are valuable characters for establishing the phylogenetic history of eukaryotes. Answer: FALSE - they can be lost (in lecture handout) 2. You are worried the potatoes you planted this
Cornell - BIOEE - 2780
Which fungi phyla form mycorrhizae? A. Ascomycota B. Basidiomycota C. Glomeromycota D. B &amp; C E. A, B &amp; C Which of the following is not a synapomorphy for Kingdom Animalia? A. distinctive collagen B. desmosomes C. Hox genes D. nerves E. muscles Which of th
Cornell - BIOEE - 2780
BioEE 2780 Evolutionary Biology &amp; DiversityFall 2009 Irby Lovette (lead professor)When you have seen one ant, one bird, one tree, you have not seen them all. biologist E. O. Wison Nothing in Biology makes sense but in the light of Evolution. geneticist
Cornell - CHEM - 3570
Chem 1057 J. WalcottCENTER FOR LEARNING AND TEACHING LEARNING STRATEGIES CENTER Fall 2009Review Guide #1Chapter 1I. Review of Concepts from General Chemistry A. An atomic orbital is a description of the wave properties of an electron in an atom. A thr
Cornell - CHEM - 3570
Chem 1057 J. WalcottCENTER FOR LEARNING AND TEACHING LEARNING STRATEGIES CENTER Fall 2009Review Guide #2Lecture: 8/31/09 9/4/09: Chapter 1I. Lewis Structures and Formal Charges Please refer to Review Guide #1 for the general procedure for writing Lewi
Cornell - CHEM - 3570
Chem 1057 J. WalcottCENTER FOR LEARNING AND TEACHING LEARNING STRATEGIES CENTER Fall 2009Review Guide #3Lectures: 9/7/09 9/11/09 Chapter 2I. Hydrocarbons Hydrocarbons are compounds that contain only the elements carbon and hydrogen. Alkanes are alipha
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #4Lectures: 9/14/09 9/18/09 and Chapters 3 and 5I. Alkenes 2 Any molecule with a carbon - carbon double bond is an alkene. The carbons are sp hybridized with bond angles of 120. Six
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #5Lectures: 9/21/09 9/25/09: Chapter 4I. Alkene Stability Alkyl substiuents bonded to the sp carbons of an alkene have a stabilizing effect on the alkene due to hyperconjugation. The
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #6Lectures: 9/28/09 10/2/09: Chapters 4 and 5I. Three types of Alkene Addition Reactions (continued from Review Guide #5) A. Syn-Anti Addition 1. Hydrohalogenation (add HX) 2. Hydrat
Cornell - CHEM - 3570
Chem1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #7Lectures: 10/5/09 10/16/09: Chapters 4, 6 and 7I. Alkene Addition Reactions (continued from Review Guide #6) A. Syn-Anti Addition 1. Hydrohalogenation (adds H-X) 2. Hydration (adds
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #8Lectures: 10/19/09 10/23/09: Chapters 7 and 8I. The Diels Alder Reaction Conjugated dienes undergo cycloaddtion reactions with dienophiles to give cyclic products. The four carbon
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #9Lectures: 10/26/09 10/30/09 : Chapters 8 and 9I. Reactions of Alkyl Halides ( Please see Review Guide #8 for SN2 and E2 Reactions) A. The SN2 Reaction 1. The nucleophile replaces t
Cornell - CHEM - 3570
Chem 1057 J. Walcott LEARNING STRATEGIES CENTER Fall 2009Review Guide #10Lectures: 11/2/09 11/6/09: Chapters 10 and 11I. Ethers Ethers are generally unreactive and thereby are often used as solvents. A. Preparation 1. The Williamson ether synthesis is