Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

CIS2500

QuestionAnswer
Assume that the current folder has 5 files and they are: Makefile nuts.c vegan.c dairy.c nuts.h Which of the following command are executed when the make is run gcc -Wall -std=c99 -c dairy.c gcc -Wall -std=c99 -c nuts.c gcc -Wall -std=c99 -c ve all of the above
What is the fundamental difference between the commands git commit and git push? commit saves changes to local repository; push uploads those changes to the GitLab
When using fopen(filename, "w"), what happens if the file specified by filename already exists? The existing contents are erased (the file is truncated to zero length).
typedef struct { int x; int y; } Point; Point *ptr; Which of the following is the correct syntax to access the member x? ptr->x
Why is strncpy(dest, src, n) considered safer than strcpy(dest, src)? It prevents buffer overflows by limiting the number of characters copied.
Which command allows you to view the "staging area" to see which files are ready to be committed? git status
On a standard 64-bit system where an int is 4 bytes, how much memory is allocated for the declaration int matrix[3][5]? 60 bytes
In a Makefile recipe, what is the specific requirement for the indentation of the command line? It must be exactly one hard Tab character.
How does the make utility decide whether or not a specific source file needs to be recompiled? It compares the last modification timestamps of the source file and the target object file.
In the following rule, which automatic variable would you use to represent ALL the dependencies (main.o, logic.o, init.o)? program: main.o logic.o init.o $^
True or False: A C struct can contain another struct as one of its members. True
If you want to move the file pointer 50 bytes backward from the current position in a binary file, which fseek call is correct? fseek(fp, -50, SEEK_CUR);
Which of the following is the correct way to check if a file was successfully opened using fopen? if (fp == NULL)
What is a primary advantage of using binary files over text files for storing large arrays of structures? Binary files allow for faster I/O because data does not need to be converted to/from string representations.
What is the "base case" in a recursive function? The condition under which the function stops calling itself.
In terms of memory, where are the local variables and return addresses of each recursive call stored? The Stack
What will be the output of ftell(fp) immediately after opening an existing 100-byte file in "rb" mode? 0
In the function call fread(ptr, size, nmemb, fp), what does nmemb represent? The number of elements, each of size bytes, to be read.
Which function is used to write a block of memory (like a struct) directly to a binary file? fwrite()
What happens if a recursive function lacks a base case? It will lead to infinite recursion and eventually a stack overflow.
What does the fgets function return when it encounters the end-of-file (EOF) before reading any characters? NULL
What is the purpose of rewind(fp) in C file handling? It moves the file position pointer to the beginning of the file.
Analyze the following code. What is the return value of mystery(3)? int mystery(int n) { if (n <= 1) return 1; return n + mystery(n - 1); } 6
Consider a recursive implementation of the Fibonacci sequence. Why is the naive version (calculating fib(n-1) + fib(n-2)) often considered inefficient? It performs a large number of redundant calculations for the same sub-problems.
What is a disadvantage of using a Singly Linked List compared to a dynamic array? It consumes more memory per record because of the 'next' pointer.
int mysteryFunction(int n, int acc) { if (n <= 1) return acc; return mysteryFunction(n - 1, n * acc); What is the value of the acc parameter in the third recursive call if the initial call is mysteryFunction(4, 1)? 12
If temp is a pointer to a LogNode object, and LogNode contains a member object named data of type LogEntry, which of the following is the correct syntax to access the userID field inside that data object? temp->data.userID
What is the primary advantage of using an accumulator variable in a tail-recursive function like the one shown in Question 1? It enables the compiler to perform tail-call optimization, reusing the same stack frame.
What is the most appropriate base case for a recursive function designed to traverse a singly linked list and count its total number of nodes? if (head == NULL)
You are writing a function void deleteFirst(LogNode **head). Why is a double pointer (**head) used instead of a single pointer (*head)? To allow the function to update the original head pointer variable in the calling function.
When creating a new node for a Singly Linked List using malloc, what is the critical step to perform immediately after allocation and before accessing its members? Check if the returned pointer is NULL to ensure allocation succeeded.
Which of the following code snippets correctly deletes a node pointed to by curr that is located between prev and curr->next? prev->next = curr->next; free(curr);
In a recursive function using an array for memoization, what is the purpose of checking the array at the start of the function logic? To check if the result for the current input has already been computed and stored.
When implementing a memoization table using a static array in C, why is it common to initialize the array elements to -1 instead of 0? Zero is a valid result for many functions, while −1 can signify that a value has not yet been computed.
What is the average time complexity of binary search? O(logn)
Which sorting algorithm is similar to sorting playing cards in your hand? Insertion Sort
In binary search, what does the variable mid represent? The middle index of the current search range
Which sorting algorithm repeatedly selects the smallest element and places it in the correct position? Selection Sort
What is the main idea behind linear search? Compare each element sequentially until the value is found
In bubble sort, what happens during each pass? Adjacent elements are compared and swapped if needed
If the target value is greater than the middle element in binary search, the algorithm searches: The right half
What is the worst-case time complexity of linear search? O(n)
Binary search requires that the array be: Sorted
Which condition terminates a linear search loop? The target is found or the end of the array is reached
What input causes the worst-case time complexity for Quick Sort when the last element is chosen as pivot? Sorted array (ascending or descending)
What is the space complexity of Merge Sort? O(n)
int add(int a, int b) { return a + b; } int (*fp)(int, int) = add; How do you correctly call the function using the pointer? fp(2, 3)
Which of the following correctly declares a function pointer to a function that takes two integers and returns an integer? int (*fp)(int, int);
In the standard Quick Sort partition (pivot = last element), what is the final position of the pivot after partitioning? Its correct sorted position
Which of the following is a common use case for function pointers? Implementing callbacks or higher-order functions
Insertion Sort performs best when: The array is already sorted or nearly sorted
What is the average-case time complexity of Quick Sort? O(n log n)
What is the best-case time complexity of Insertion Sort? O(n)
Which of the following commands is used to record changes to the repository in Git? git commit
What is the time complexity of the Merge Sort algorithm in the worst-case scenario? O(n log n)
When using fseek(fp, 0, SEEK_END), what does the next call to ftell(fp) return? The current offset from the start, effectively the file size in bytes
In a Binary Search Tree (BST), where would you find the value that is smaller than the root? Always in the left subtree
What is the primary advantage of a Linked List over an Array? Constant time O(1) insertion at the head
Which function is used to allocate memory on the heap and initialize all bits to zero? calloc()
What happens if a recursive function does not have a base case? It will result in a Stack Overflow at runtime
A Stack data structure follows which principle? LIFO (Last-In, First-Out)
T or F Binary files are generally more compact and faster to process than text files for large datasets True
T or F In C, a function pointer can be used to pass a function as an argument to another function True
The free() function automatically sets the pointer to NULL after deallocating memory False
Selection Sort always performs O(n^2) comparisons, regardless of whether the array is already sorted True
the debugger tool used in Linux to step through C code line by line is called ________ gbd
In a Makefile, the variable typically used to specify the compiler is _________ CC
A structure that contains a pointer to a structure of the same type is known as a _______ structure self-referentia
The process of storing results of expensive function calls to avoid redundant calculations in recursion is called _________ memoization
Write a C function to prepend a new node (containing an integer val) to a singly linked list typedef struct Node { int data; struct Node *next; } Node; Node* prepend(Node *head, int val) { // Your code here }
Why must an array be sorted before applying the Binary Search algorithm? Binary Search works by repeatedly dividing the search interval in half and deciding which half to keep searching. This decision is only possible if the array is sorted
What is the time complexity of searching for an element in an unsorted array of size n? Searching an unsorted array takes O(n) time
Quick Sort: Show the steps of partitioning the following array using the last element as the pivot: [12, 7, 14, 9, 10] Pivot = 10, [12, 7, 14, 9, 10], [7, 12, 14, 9, 10] [7, 9, 14, 12, 10] Final array after partition: [7, 9, 10, 12, 14]
Binary Search Tree: Draw the resulting BST after inserting the following keys in order: 50, 30, 70, 20, 40, 60, 80 50 / \ 30 70 / \ / \ 20 40 60 80
Recursion Tracing: What is the output of mystery(3)? int mystery(int n) { if (n <= 1) return 1; return n + mystery(n - 1) + mystery(n - 2); } - mystery(3) = 3 + mystery(2) + mystery(1) - mystery(1) = 1 (Base case) - mystery(2) = 2 + mystery(1) + mystery(0) - mystery(0) = 1 (Base case) - Solve mystery(2): 2 + 1 + 1 = 4 - Solve mystery(3): 3 + 4 + 1 = 8 - Result: 8
Created by: jayne_
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards