Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heap part js code #339

Merged
merged 7 commits into from
Feb 7, 2023
Merged

Add heap part js code #339

merged 7 commits into from
Feb 7, 2023

Conversation

what-is-me
Copy link
Contributor

If this PR is related to coding or code translation, please read the contribution guideline, fill out the checklist, and paste the console outputs to the PR.

  • I've tested the code and ensured the outputs are the same as the outputs of reference codes.
  • I've checked the codes (formatting, comments, indentation, file header, etc) carefully.
  • The code does not rely on a particular environment or IDE and can be executed on a standard system (Win, macOS, Ubuntu).

输入列表并建堆后
堆的数组表示:    
[
  9, 8, 6, 6, 7,  
  5, 2, 1, 4, 3,  
  6, 2
]
堆的树状表示:    
        /——— 2    
    /——— 6        
   |    \——— 5    
   |        \——— 2
——— 9
   |        /——— 6
   |    /——— 7    
   |   |    \——— 3
    \——— 8        
       |    /——— 4
        \——— 6    
            \——— 1

堆顶元素为 9

元素 7 入堆后
堆的数组表示:
[
  9, 8, 7, 6, 7, 6,
  2, 1, 4, 3, 6, 2,
  5
]
堆的树状表示:
        /——— 2
    /——— 7
   |   |    /——— 5
   |    \——— 6
   |        \——— 2
——— 9
   |        /——— 6
   |    /——— 7
   |   |    \——— 3
    \——— 8
       |    /——— 4
        \——— 6
            \——— 1

堆顶元素 9 出堆后
堆的数组表示:
[
  8, 7, 7, 6, 6,
  6, 2, 1, 4, 3,
  5, 2
]
堆的树状表示:
        /——— 2
    /——— 7
   |    \——— 6
   |        \——— 2
——— 8
   |        /——— 5
   |    /——— 6
   |   |    \——— 3
    \——— 7
       |    /——— 4
        \——— 6
            \——— 1

堆元素数量为 12

堆是否为空 false

js没有内置堆类

@vercel
Copy link

vercel bot commented Feb 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
hello-algo ⬜️ Ignored (Inspect) Feb 7, 2023 at 11:41AM (UTC)

@krahets
Copy link
Owner

krahets commented Feb 6, 2023

Pending for review by @justin-tse

Copy link
Contributor

@justin-tse justin-tse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@what-is-me Thanks! Please address the comments.

codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
codes/javascript/chapter_heap/my_heap.js Outdated Show resolved Hide resolved
Copy link
Contributor

@justin-tse justin-tse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks @what-is-me

codes/javascript/include/PrintUtil.js Outdated Show resolved Hide resolved
@krahets krahets merged commit 7666632 into krahets:main Feb 7, 2023
@krahets krahets added the code Code-related label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants