Linked list oj question&& Linked list and LinkedList && The concept of stack&& The concept of queue&& Tree and binary tree

Question 1 (Programming question)

Question name:

Find the entry point of the ring

Question content:

The entry point for finding cycles icon-default.png?t=N7T8https://leetcode-cn.com/problems/linked-list-cycle-ii/description/

Question 2 (Programming question)

Question name:

Judgment chain watch ring

Question content:

Determine linked list cycle icon-default.png?t=N7T8https://leetcode-cn.com/problems/linked-list-cycle/description/

Question 3 (Programming question)

Question name:

Determine the intersection of linked lists

Question content:

Determine the intersection of linked lists and find the intersection icon-default.png?t=N7T8https://leetcode-cn.com/problems/intersection-of-two-linked-lists/description/

Question 4 (Programming question)

Question name:

Determine whether the linked list is a palindrome

Question content:

Determine whether the linked list is a palindrome icon-default.png?t=N7T8https://www.nowcoder.com/practice/d281619e4b3e4a60a2cc66ea32855bfa?tpId=49&&tqId=29370&rp=1&ru=/activity/oj&qru=/ta/2016test/question-ranking

Question 5 (Programming question)

Question name:

Given x, organize a linked list into a form where the first half is less than x and the second half is greater than or equal to x.

Question content:

Given x, organize a linked list into a form where the first half is less than x and the second half is greater than or equal to x icon-default.png?t=N7T8https://www.nowcoder.com/practice/0e27e0b064de4eacac178676ef9c9d70?tpId=8&&tqId=11004&rp=2&ru=/activity/oj&qru=/ ta/cracking-the-coding-interview/question-ranking

 

Question 1 (single choice question)

Question name:

8. In a circular doubly linked list, the node pointed to by s should be inserted before the node pointed by p. The correct execution order of the following code is ( )

   ① p.prev.next=s;

   ② p.prev=s;

   ③ s.prev=p.prev;

   ④ s.next=p;

Question content:

A .④③①②

B .④③②①

C .②①④③

D .②①③④

Question 2 (single choice question)

Question name:

7. Among the following statements that determine whether the bidirectional circular linked list of the leading node is empty, which one is correct ( )

Question content:

A .head == null;

B .head.next == null;

C .head.next == head;

D .head != null;

Question 3 (Programming question)

Question name:

Simulate the LinkedList class

Question content:

 // 2、无头双向链表实现
 public class LinkedList {
     //头插法
     public void addFirst(int data);
     //尾插法
     public void addLast(int data);
     //任意位置插入,第一个数据节点为0号下标
     public boolean addIndex(int index,int data);
     //查找是否包含关键字key是否在单链表当中
     public boolean contains(int key);
     //删除第一次出现关键字为key的节点
     public void remove(int key);
     //删除所有值为key的节点
     public void removeAllKey(int key);
     //得到单链表的长度
     public int size();
     public void display();
     public void clear();
 }

Question 1 (single choice question)

Question name:

1. Which of the following statements about stacks is correct ( )

Question content:

A. The stack is a "first in first out" data structure

B. The stack can be implemented using a linked list or a sequential list

C. The stack can only insert data at the bottom of the stack

D. The stack cannot delete data

Question 2 (single choice question)

Question name:

2. The push sequence of a stack is ABCDE, and the impossible pop sequence is ( )

Question content:

A .ABCDE

B .EDCBA

C .DCEBA

D.ECDBA

Question 3 (single choice question)

Question name:

3. Compared with the sequential stack, the obvious advantages of the chain stack are ( )

Question content:

A. Insertion operation is more convenient

B. Deletion operation is more convenient

C. No expansion is required when pushing into the stack

Question 4 (single choice question)

Question name:

4. Among the following statements about stacks, which one is correct ()

Question content:

A. The element at the bottom of the stack must be the last element pushed onto the stack.

B. The top element of the stack must be the first element pushed onto the stack.

C. Stack operations follow the first-in, last-out principle

D. All the above statements are wrong

Question 5 (single choice question)

Question name:

5. Input four elements A, B, C, and D with the help of the stack (pushing and popping can be interspersed), then the impossible output is

Question content:

A .DCBA

B .ABCD

C .CBAD

D .CABD

Question 6 (Programming question)

Question name:

Minimum stack

Question content:

Minimum stack

Question 7 (Programming question)

Question name:

1. Bracket matching problem

Question content:

1. Bracket matching problem. OJ link

Question 8 (Programming question)

Question name:

3. Stack pop-up sequence

Question content:

The pop-up and push sequence of the stack (just upload the code). OJ link

Question 9 (Programming question)

Question name:

4. Evaluating reverse Polish expressions

Question content:

Evaluate reverse Polish expressions (just upload the code). OJ link

Question 1 (single choice question)

Question name:

7. Which of the following is not a basic operation of the queue ( )

Question content:

A. Insert a new element from the end of the queue

B. Delete the tail element from the queue

C. Determine whether a queue is empty

D. Read the value of the head element of the queue

Question 2 (multiple choice)

Question name:

8. Which of the following statements about stacks and queues is wrong ( )

Question content:

A. Queues and stacks are usually implemented using linked lists

B. Queues and stacks can only insert and delete data from both ends.

C. Neither the queue nor the stack supports random access and random insertion.

D. The queue is "first in, first out" and the stack is "first in, first out"

Question 3 (single choice question)

Question name:

9. Which of the following statements about the sequential structure to implement circular queues is correct ( )

Question content:

A. The length of the circular queue is usually not fixed.

B. You can directly use the head and tail of the queue to be at the same position to determine whether the circular queue is full.

C. You can determine whether the queue is empty or full by setting the count.

D. Circular queue is a non-linear data structure

Question 4 (single choice question)

Question name:

10. There is an existing circular queue, with the head of the queue being front and the tail being rear. The length of the circular queue is N and a maximum of N-1 data can be stored. The effective length within the team is ( )

Question content:

A .(rear - front + N) % N + 1

B .(rear - front + N) % N

C .(rear - front) % (N + 1)

D .(rear - front + N) % (N - 1)

Question 5 (single choice question)

Question name:

1. For circular queues, which of the following statements is correct?

Question content:

A. The head of the team is fixed

B. The head of the team must be greater than the tail of the team

C. The head of the team must be smaller than the tail of the team

D. The head of the team can be greater than the tail of the team, or it can be smaller than the tail of the team.

Question 6 (single choice question)

Question name:

2. Which of the following statements about the difference between stacks and queues is wrong?

Question content:

A. The stack is limited to insertion and deletion operations only at one end of the table.

B. The queue is limited to insertion operations at one end of the table and deletion operations at the other end.

C. Both stacks and queues belong to linear lists

D. The time complexity of the insertion operation of the stack is o(1), and the time complexity of the insertion operation of the queue is o(n)

Question 7 (single choice question)

Question name:

4. Which of the following statements about using stacks to implement queues is incorrect ( )

Question content:

A. To implement a queue using stack simulation, you can use two stacks, one stack simulates entering the queue, and one stack simulates leaving the queue.

B. Every time you dequeue, you need to import all the elements in one stack into another stack and then pop it out.

C. When entering the queue, just store the elements directly in the stack that simulates entering the queue.

D. The time complexity of the queue operation is O(1)

Question 8 (single choice question)

Question name:

Which of the following statements about queues is incorrect ( )

Question content:

A. Queues can be implemented using linked lists

B. Queue is a "first in, first out" data structure

C. When data is dequeued, only the tail reference will be affected.

D. When data is put into the queue, it must be inserted from the tail.

Question 9 (Programming question)

Question name:

Implementing a stack using queues

Question content:

Implementing a stack using queues

Question 10 (Programming question)

Question name:

Implement queue using stack

Question content:

Implement queue using stack

Question 11 (Programming question)

Question name:

Design circular queue

Question content:

Design circular queue

Question 12 (single choice question)

Question name:

Use a headless singly linked list to store the queue, front refers to the head of the queue, and back refers to the tail of the queue, when performing a dequeue operation ( )

Question content:

A. Only modify the front

B. Both front and back must be modified.

C. Both front and back may need to be modified.

D. Only modify back

Question 1 (single choice question)

Question name:

2. Start a complete binary tree with 100 nodes from the root level, and number the nodes in each level from left to right. The root node number is 1, then the parent node number of the node numbered 98 for

Question content:

A .47

B .48

C .49

D .50

Question 2 (single choice question)

Question name:

3. Suppose that in all subtrees of a non-empty binary tree, the node values ​​on the left subtree are less than the root node value, and the node values ​​on the right subtree are not less than the root node value, then the binary tree is called Sorted binary tree. The result of traversing a sorted binary tree is an ordered sequence.

Question content:

A. Intermediate sequence

B. Preamble sequence

C. Postorder sequence

D. Pre-order sequence or post-order sequence

Question 3 (single choice question)

Question name:

17. For any binary tree, assuming N0, N1, and N2 are the number of nodes with degrees 0, 1, and 2 respectively, then the following formula must be correct ( )

Question content:

A .N0 = N2 + 1

B .N1 = N0 + 1

C .N2 = N0 + 1

D .N2 = N1 + 1

Question 4 (single choice question)

Question name:

19. ( ) traversal of a binary tree is equivalent to breadth-first traversal, and ( ) traversal is equivalent to depth-first traversal.

Question content:

A. Preorder, middle order

B. Mid-order preorder

C.Later sequence

D. Pre-sequence of layer sequence

Question 5 (single choice question)

Question name:

20. If the result of the preorder traversal of a binary tree is ABCD, then there are ( ) different binary trees that meet the conditions.

Question content:

A .13

B .14

C .15

D .16

Question 6 (single choice question)

Question name:

10.The depth of a complete binary tree with n elements is ( )

Question content:

A .nlogn

B .nlogn+1

C .logn

D .logn+1

Question 7 (single choice question)

Question name:

1. How many levels can a complete binary tree with n nodes have at most?

Question content:

A .n/2

B .log(n)+1(round down)

C .n-1

D .n

Question 8 (single choice question)

Question name:

4. Put the root node of a binary tree into the queue, and then recursively perform the following operations to add all the child nodes of the dequeued node to the queue first left and then right. What kind of traversal can be achieved with the above operation?

Question content:

A. Preorder traversal

B. In-order traversal

C. Postorder traversal

D. Layer-order traversal

Supongo que te gusta

Origin blog.csdn.net/weixin_64308540/article/details/132881611
Recomendado
Clasificación