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

  • Home
  • SEARCH
  • 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 8640477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:17:22+00:00 2026-06-12T11:17:22+00:00

Functions in scheme/racket. Working on a few functions using a binary search tree. I

  • 0

Functions in scheme/racket.
Working on a few functions using a binary search tree. I have already defined helper functions to be:

;; returns value of node
(define (value node)
    (if (null? node) '()
        (car node)))

;; returns left subtree of node
(define (left node)
    (if (null? node) '()
    (cadr node)))

;; returns right subtree of node
(define (right node)
    (if (null? node) '()
    (caddr node)))

and I am trying to write a function size that takes a tree as a parameter and returns the number of non-null nodes in the given tree

  • 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-12T11:17:23+00:00Added an answer on June 12, 2026 at 11:17 am

    It seems you’re very close. Try this (untested):

    (define (size tree)
      (if (null? tree) 0
          (+ 1 (size (left tree)) (size (right tree)))))
    

    Though, personally, I would much rather prefer to use #f as the null value, rather than '(). In that case, use not instead of null? in the first line.

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

Sidebar

Related Questions

I am a noob at Scheme. I have a binary search tree. The format
I'm using R5RS Scheme and I just want to implement a function that returns
Sometimes in Scheme, I have functions that take arguments like this add 3 4
Just started learning Scheme. I'm using Dr. Racket as my compiler/interpreter. I need some
I understand that functions in Scheme/Racket like map, foldr, and filter, can do wonderful
Currently learning Scheme/Racket and have problem running this piece of code. (if (or (<
I am currently using racket scheme with DrRacket as the editor for some exploratory
So I'm teaching myself functional programming using Racket Scheme, and I love it so
What is the difference between two functions in Scheme, one defined like this— (define
While translating some Fortran to Scheme/Racket I have come across the function: ; EPSILON(X)

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.