1625 - Lee Quiz 2 Scoreboard

Time

2019/03/19 13:20:00 2019/03/19 15:10:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12163 Linked List
12184 Binary Tree Operations II

12163 - Linked List   

Description

The problem will give you mutiple lists of data and mutiple commands. Each data will be stored in one node, 
the new data will be inserted to the head of the list.

There will be 4 kinds of commands :

  1. I [data]: insert a new data into the list.
  2. RA: link a reversal duplication at the end of the list
  3. DA: link a duplication at the end of the list
  4. S : show all the data in the list ( if the list is empty, then output NULL). 

strlen(data) <= 20

numbers of all commands <= 40

numbers of RA/DA commands <= 10

max list length <= 10^5

Hint: 

character array copy

#include <string.h>

char * strncpy ( char * destination, const char * source, size_t num );

you don't have to follow this  Architecture, it's just a hint

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
    char data[21];
    struct _Node *next;
    struct _Node *prev;
} Node;

int main()
{
    int times;
    char cmd[3];

    scanf("%d",&times);
    while(times--)
    {
        scanf("%s", cmd);
        if(strncmp (cmd,"I",2)==0)
        {

        }
        else if(strncmp (cmd,"RA",2)==0)
        {

        }
        else if(strncmp (cmd,"DA",2)==0)
        {
     

        }
        else if(strncmp (cmd,"S",2)==0)
        {
   
        }
    }
    return 0;
}

 

Input

First line will contain one integer inplying how many command will be constructed
Following line will be the input instruction

 

Output

Every output will be seperated by a blank.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12184 - Binary Tree Operations II   

Description

This is a partial judge problem (Judge Language :  C)

Please download the partial judge code and header.

Then, implement 2 functions : buildTree() and showPreorder()

You have to build the binary tree according to its inorder and postorder.

Next , print out the preorder of the binary tree!

 

 

 

Submit format:

#include <stdio.h>

#include <stdlib.h>

#include "function.h"

Node* buildTree(int* inorder, int* preorder, int inorder_start, int inorder_end){

        /*YOUR CODE HERE*/

}

void showPreorder(Node* root){
      /*YOUR CODE HERE*/

}

Input

There are 3 lines for inputs.

The first line contains an integer N , which indicates the number of nodes of the binary tree.

The second line is the inorder traversal of the binary tree

The third line is the postorder traversal of the binary tree

※Note that there are not duplicated integers in the binary tree

Output

Print out the preorder traversal of the binary tree.

Note that :

1.There is an whitespace between each integer. 

2.There is an whitespace after the last integer.

3.Threre is no need to add "\n" at last 

Sample Input  Download

Sample Output  Download

Partial Judge Code

12184.c

Partial Judge Header

12184.h

Tags




Discuss