Consider the following union declaration:
This declaration illustrates that structures can be embedded within unions.
The following function (with some expressions omitted) operates on a linked list having these unions as list elements:
- A.What are the offsets (in bytes) of the following fields:
e1.p | ______ |
e1.y | ______ |
e2.x | ______ |
e2.next | ______ |
- B. How many total bytes does the structure require?
- C. The compiler generates the following assembly code for proc;
On the basis of this information, fill in the mining expressions in the code for proc. Hint: Some union references can have ambiguous interpretations. These ambiguities get resolved as you see where the references lead. There is only one answer that does not perform any casting and does not violate any type constraints.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Software Engineering (10th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Python (4th Edition)
- Write a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this: Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by…arrow_forwardhead = (node *)malloc(sizeof(node)); which returns a pointer to a structure of type node that has been type defined earlier. The linked list is then created by the function create. The function requests for the number to be placed in the current node that has been created. If the value assigned to the current node is -999, then null is assigned to the pointer variable next and the list ends. Otherwise, memory space is allocated to the next node using again the malloc function and the next value is placed into it. Not that the function create calls itself recursively and the process will continue until we enter the number -999. The items stored in the linked list are printed using the function print which accept a pointer to the current node as an argument. It is a recursive function and stops when it receives a NULL pointer. Printing algorithm is as follows; 1. Start with the first node. 2. While there are valid nodes left to print a) print the current item and b) advance to next node…arrow_forward3. Create a Memory structure owns number of block, block size, and stack attributes. You can add more attributes if it eases your implemen- tations. Stack attribute represents memory blocks. Number of block attribute rep- resents the length of the stack. Block size represents the maximum value that each element in the stack can get. 4. Write an allocate function that takes a size parameter. If the given size is bigger than block size of the Memory, the allocation will be distributed to the different blocks in the stack attribute. For example, calling allocate(27) updates the stack as allocate(27) = [10, 10, 7, 0, 0] for a Memory with number of block = 5, block size = 10. The remaining of the elements which don’t have maximum value can be sealed until the element is flushed. Therefore, the next allocation can start from next element position after 7 given above. 5. Write an deallocate function that flushes the last used block.arrow_forward
- # viewGame(G, i) takes a game description G (a dictionary of the type# produced by newGame()) and an integer player index i and returns a# string that, when printed, describes the state of the game from# player i's perspective.## Example:# >>> viewGame(G, 1)# '\nPlayer2 to play (score=0):\n 1[ ] 2[ ] 3[ ]'## Note the spacing and explicit newlines, and the fact that the player# numbers use 1-based indexing even though internally the game data# structures use Pythonic 0-based indexing.arrow_forwardIn C++ data structure Please write program per instructions. Thank you A set is a collection of distinct elements of the same type. Design the class unorderedSetType, derived from the unorderedArrayListType, to manipulate sets. Note that you need to redefine only the f unctions insertAt, insertEnd, and replaceAt. If the item to be inserted is already in the list, the functions insertAt and insertEnd output an appropriate message. Similarly, if the item to be replaced is already in the list, the function replaceAt outputs and appropriate message. Also, write a program to test your class: then Redo the program using templatesarrow_forward13. Star topology is an arrangement of the network in which every node is connected to the central hub, switch, or central computer. True False 14. Queue is referred to be as First-In-First-Out (FIFO) list. True False 15. Linked list is more suitable data structure than array for a program that requires a lot of insert/erase operations. True False 16. An algorithm of the order O(c") runs faster than a one of the order O(n!), where n is size of input and c is a positive constant. True False 17. The notation O(n) is the formal way to express both the lower bound and the upper bound of an algorithm's running time. True False 18. One of the advantages of File-Based database is separation of data. True False 19. In NOSQL, data is placed in tables, and data schema is perfectly designed before the database is built. True False 20. In ERD representation, derived attributes are depicted by double ellipses. True Falsearrow_forward
- This chapter describes the array implementation of queues that use a special array slot, called the reserved slot, to distinguish between an empty and a full queue. Write the definition of the class and the definitions of the function members of this queue design. Also, write a program (in main.cpp) to test various operations on a queue. //Header file QueueAsArray #ifndef H_QueueAsArray #define H_QueueAsArray #include <iostream> #include <cassert> using namespace std; template<class Type> class queueType { public: const queueType<Type>& operator=(const queueType<Type>&); // overload the assignment operator void initializeQueue(); int isEmptyQueue() const; int isFullQueue() const; Type front() const; Type back() const; void addQueue(Type queueElement); void deleteQueue(); queueType(int queueSize = 100); queueType(const queueType<Type>& otherQueue); // copy constructor…arrow_forwardSKELETON CODE IS PROVIDED ALONG WITH C AND H FILES. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include "node.h" #include "stack_functions.h" #define NUM_VERTICES 10 /** This function takes a pointer to the adjacency matrix of a Graph and the size of this matrix as arguments and prints the matrix */ void print_graph(int * graph, int size); /** This function takes a pointer to the adjacency matrix of a Graph, the size of this matrix, the source and dest node numbers along with the weight or cost of the edge and fills the adjacency matrix accordingly. */ void add_edge(int * graph, int size, int src, int dst, int cost); /** This function takes a pointer to the adjacency matrix of a graph, the size of this matrix, source and destination vertex numbers as inputs and prints out the path from the source vertex to the destination vertex. It also prints the total cost of this…arrow_forwardA dequeue is a list from which elements can be inserted or deleted at either end a. Develop an array based implementation for dequeue. b. Develop a pointer based implementation dequeue.arrow_forward
- Write a C++ program to implement movie rent store, using Linked List, which will allow the store owner to perform the following functions:a) Insert the new Movie cassettes/CD record in store.b) Delete the record of the existing movie record by record id.c) Display available movie cassettes/CD record.d) Rent out movies cassettes/CDe) Display rented cassettes/CD records.Following details should be displayed against each record:Record Id, Name, Genre, Release Date, Movie Length, Production House, Rented Datearrow_forwardRead this: Complete the code in Visual Studio using C++ Programming Language with 1 file or clear answer!! - Give me the answer in Visual Studio so I can copy*** - Separate the files such as .cpp, .h, or .main if any! Develop a C++ "doubly" linked list class of your own that can hold a series of signed shorts Develop the following functionality: Develop a linked list node struct/class You can use it as a subclass like in the book (Class contained inside a class) You can use it as its own separate class Your choice Maintain a private pointer to a node class pointer (head) Constructor Initialize head pointer to null Destructor Make sure to properly delete every node in your linked list push_front(value) Insert the value at the front of the linked list pop_front() Remove the node at the front of the linked list If empty, this is a no operation operator << Display the contents of the linked list just like you would print a character…arrow_forwardAdd the following functions and write a program to test these functions in the classlinkedListType:a. Write the definition of a function that returns the data of the kth element of the linked list. If suchelement is not exist in the list, exit the program. (05)b. Write the definition of a function that deletes the kth element of the linked list. If such element isnot exist in the list, exit the program and display message as output.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning