Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:06:15+00:00 2026-06-13T14:06:15+00:00

So I’m working on a program which is supposed to ‘heapify’ integers that a

  • 0

So I’m working on a program which is supposed to ‘heapify’ integers that a user adds to a set, among other things. I’m having a problem right now, however, when I try to access the left child node of a Node which was passed as a parameter to a function. Visual Works runs out of memory…

The odd thing is that in the debugger, I can see that the Left child node of the passed node was created and assigned to the passed node correctly. But when I try to access it via the source code, I get a crazy memory error.

Here is the corresponding code. Hopefully it is readable

The function in which the error occurs, once it is called:

addLeftChildTo: aNode

"Determine Left child of passed node. Set that child's parent node as self. Imprint the index where that value was retrieved from the array."

| temp leftChildIndex |
2 * aNode indexOfNode <= arrayOfInput size
    ifTrue: 
        [leftChildIndex := 2 * aNode indexOfNode.
        aNode left: (arrayOfInput at: leftChildIndex).
        aNode left parentNode: aNode.                   <---VW Runs out of memory and crashes here. This occurs once the debugger dives into the 'left' accessor method of the passed aNode object.
        aNode left indexOfNode: leftChildIndex.
        self bubbleUp: aNode left.
        self bubbleUpArrayOfInput: aNode left]
    ifFalse: [aNode left: nil]

Here are the accessor methods of ‘left’ for the BinaryHeapNode class

left

    ^self left

left: aValue

    left := BinaryHeapNode new: aValue.

And in case it’s helpful to see the code that originally calls the addLeftChildTo: method…

populateHeap
"from passed array of input"
"Add a node (typically a node with an element from the ArrayOfInput) to the heap. Bubble up as you go."

| temp |
rootNode isNil
    ifTrue: 
        [rootNode := BinaryHeapNode new: (arrayOfInput at: 1).
        rootNode indexOfNode: indexOfArray.

        self addLeftChildTo: rootNode.   <--- Call to function with problematic code. 
                    ...

I don’t understand what I’m doing wrong and I’ve been stuck on this problem for a couple of hours. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:06:16+00:00Added an answer on June 13, 2026 at 2:06 pm

    You made an infinite recursion with accessor #left:

    left
      ^self left
    

    This method actually calls itself. Return just instance variable ^left instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.