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&MOD MSGT/ET SA AC PKG
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)
- head = (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_forwardImplement in C Programming 9.10.1: LAB: Movie show time display Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Hints: Use…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_forwardThis 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_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
- In 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_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_forwardWrite 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_forward
- A 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_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_forwardUnique Words (Python) It seems like we need to use linked lists. Summary Specifications:You are tasked to implement an abstract data type class which takes in a given input file called input.txt, and processes, identifies and sorts all unique word instances found in the file. Sample InputHi hello hi good bye goodbye Bye bye good say Sample OutputBye Hi bye hello hi say The input.txt file is found along with the zip folder where this instructions file also came along with. Note: you are not allowed to use pythonic lists, and its methods and functions, and string methods. However the use of the file handling methods (read readlines and readline) are allowed for this project.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning