Giter Club home page Giter Club logo

2023_ds_hw2_in_ncku's Introduction

Review Assignment Due Date Review Assignment Due Date

2023_DS_Fall_Homework 2

Execution environment and Constraint.

  • CPU core: 1
  • Memory: 2 GB
  • Execution time limit: 1 second
  • C Compiler: GCC
    • compiled with -O3 -std=c11 -Wall
  • C Standard: C11
  • Use header file only from C Standard Library
  • OS: Ubuntu 22.04.1 LTS

Problem 1: Priority Queue (3%)

Write a C function to create an empty F-heap and support the following instructions. Each line in the input file represents one instruction.

  1. insert x val : insert an element with key x
  2. extract : print out the minimum in the heap and delete it
  3. delete x val : delete the node which has key x and value val
  4. decrease x val y : decrease the key by y on the node which has key x and value y
  5. quit : terminate the program

Note that all operations must leave behind properly structured F-heaps. Your functions for (3) and (4) must perform cascading cuts.

Constraints

  • โˆ’2147483648 โ‰ค ๐‘ฅ, val โ‰ค 2147483647
  • 1 โ‰ค ๐‘ฆ โ‰ค 2147483647
  • 2 โ‰ค ๐‘› โ‰ค 105, ๐‘› is number of instructions
  • The key after decreasing will not exceed the boundary of 32-bit signed integer.

Problem 2: Efficient Binary Search Tree (10%)

Program the search, insert, and delete operations for red-black trees.

  1. search x : Print out the color of the tree node if the element x exists. If the element x does not exist, print out "Not found\n".
  2. insert x : Add an integer x to the red-black tree. If x already exists, do nothing.
  3. delete x : Delete the element x if the element x exists. (Note: The textbook did not describe how to implement delete on red-black tree. Students can write your own delete to satisfy the constraint of the red-black tree.)

The instructions are insert, search, delete and quit. Instruction quit means you should terminate your program.

Get Started

Please make sure that git, gcc & make has been installed successfully.

Run

$ make

to compile the src files.

You can now enter the output directory and check out the outputs.

For testing, simly run

$ chmod +x test.sh
$ ./test.sh

to check if the output is valid.

2023_ds_hw2_in_ncku's People

Contributors

dodo920306 avatar github-classroom[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.