Question

1. static int function(int n){ return n * function(n + 1); } If you call the...

1.

static int function(int n){
     
        return n * function(n + 1);
}

If you call the method function(2), the expected output is 3.

True
False

2.

public void push(int new_data)
{
    Node new_Node = new Node(new_data);

    new_Node.next = head;
    new_Node.prev = null;

    if (head != null)
        head.prev = new_Node;

    head = new_Node;
}

The code snippet depicts stack implementation
True
False

3.

A ________ list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes.

Single-linked
doubly-linked
Recursion

4.

Which one of the following statements about stacks is incorrect?

Stacks can be implemented using linked lists.
Stacks are first-in, first-out (FIFO) data structures.
New nodes can only be added to the top of the stack.

The last node (at the bottom) of a stack has a null (0) link.

5.

In general, linked lists allow:

Insertions and removals anywhere.
Insertions and removals only at one end.
Insertions at the back and removals from the front.
None of the above.

6.

How many pointers are contained as data members in the nodes of a circular, doubly linked list of integers with five nodes?

3
15
8
10
0 0
Add a comment Improve this question Transcribed image text
Answer #1
1)  False
2)  True
3)  doubly-linked
4)  Stacks are first-in, first-out (FIFO) data structures.
5)  Insertions and removals anywhere.
6)  10
Add a comment
Know the answer?
Add Answer to:
1. static int function(int n){ return n * function(n + 1); } If you call the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Am Specification For this assignment, you will write a multi-file C program to define, implement ...

    Must be written and C, and compile with MinGW. Thank you! am Specification For this assignment, you will write a multi-file C program to define, implement and use a dynamic linked lists. Please refer to Lab 07 for the definition of a basic linked list. In this assignment you will need to use the basic ideas of a node and of a linked list of nodes to implement a suit of functions which can be used to create and maintain...

  • ****find_last_node.c #include <stdio.h> #include "linked_list.h" int main(){    ...

    ****find_last_node.c #include <stdio.h> #include "linked_list.h" int main(){       struct node *linked_list = NULL;    linked_list = add_to_list(linked_list, 5, 'a');    linked_list = add_to_list(linked_list, 10, 'b');    linked_list = add_to_list(linked_list, 4, 'c');    linked_list = add_to_list(linked_list, 10, 'd');    linked_list = add_to_list(linked_list, 5, 'e');    linked_list = add_to_list(linked_list, 7, 'f');    linked_list = add_to_list(linked_list, 5, 'g');    linked_list = add_to_list(linked_list, 3, 'h');    int search_number;    printf("Enter number you want to search for:");    scanf("%d", &search_number);    struct node *last_node = find_last(linked_list, search_number);    if (last_node != NULL)    {        printf("Node found: value = %d and...

  • This is a c programming problem. Would you please help me to write this problem??? I...

    This is a c programming problem. Would you please help me to write this problem??? I really appreciate it if you add comments for explanation step by step. Thank you. Reverse a Doubly linked list using recursion: Given a doubly linked list. Reverse it using recursion. Original Doubly linked list: next pointer - DDHIHI Null prev painter Reversed Doubly linked list: next pointer Start Pointer Null prev pointer Include: a) A struct for a node of the doubly linked list....

  • Linked Lists: Suppose you have a doubly linked list with both head and tail pointers, that...

    Linked Lists: Suppose you have a doubly linked list with both head and tail pointers, that stores integers. Implement a non-recursive function that takes a linked list, searches for an integer, and removes the node with the first occurrence of that integer and also removes the node directly after it regardless of value . This function will return to address of the resulting list. You ca n assume that there will be at least three nodes, and if there is...

  • Answer all questions 1- in circular singly linked list, previous pointer of the first node points...

    Answer all questions 1- in circular singly linked list, previous pointer of the first node points to which node A. First node B. Itself C. null D. Last node 2- Which of the following is NOT an applications of linked lists? A. Implementation of stacks and queues B. Dynamic memory allocation C. Manipulation of polynomials D. Keeping people at home during epidemics like corona virus 3- In a circular singly linked list? A. Components are all linked together in some...

  • Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include...

    Please fill in this code to reverse a linked list: (written in C/C++) #include #include #include using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list */ void...

  • Please help me fix my errors. I would like to read and write the text file...

    Please help me fix my errors. I would like to read and write the text file in java. my function part do not have errors. below is my code import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.FileWriter; import java.io.IOException; public class LinkedList {    Node head;    class Node    {        int data;        Node next;       Node(int d)        {            data = d;            next = null;        }    }    void printMiddle()    {        Node slow_ptr...

  • #include <iostream> using namespace std; struct ListNode { float value; ListNode *next; }; ...

    #include <iostream> using namespace std; struct ListNode { float value; ListNode *next; }; ListNode *head; class LinkedList { public: int insertNode(float num); void deleteNode(float num); void destroyList(); void displayList(); LinkedList(void) {head = NULL;} ~LinkedList(void) {destroyList();} }; int LinkedList::insertNode(float num) { struct ListNode *newNode, *nodePtr = head, *prevNodePtr = NULL; newNode = new ListNode; if(newNode == NULL) { cout << "Error allocating memory for new list member!\n"; return 1; } newNode->value = num; newNode->next = NULL; if(head==NULL) { cout << "List...

  • C++ program, inventory.cpp implementation Mostly need the int load(istream&) function. Implementation: You are supp...

    C++ program, inventory.cpp implementation Mostly need the int load(istream&) function. Implementation: You are supposed to write three classes, called Item, Node and Inventory respectively Item is a plain data class with item id, name, price and quantity information accompanied by getters and setters Node is a plain linked list node class with Item pointer and next pointer (with getters/setters) Inventory is an inventory database class that provides basic linked list operations, delete load from file / formatted print functionalities. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT