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 6221285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:06:19+00:00 2026-05-24T08:06:19+00:00

In a recent question I was encouraged to try using some basic data structures

  • 0

In a recent question I was encouraged to try using some basic data structures such as binary trees, red-black trees, et cetera, before tackling other things like quadtrees.

My experience in C is fairly limited and I am fearful of using pointers for anything but simple data (like 2D grids, image storage and strings), although I am familiar with referencing, malloc, realloc and other trivial actions, I am not used to the “hard” parts of C, which makes such structures hard to tackle from theory, and I don’t want to just copy working code into this.

What I’d like to know, in order to tackle basic trees, is a practical application for them. Sort of an exercise with some guidelines (sort of “don’t do this or you will kill performance” or “don’t do that or this will leak memory”), just to be able to know the practical purpose. Even if I memorize the theory, I still don’t know what sort of experiment to conduct in order to understand their application.

I am mostly attempting to use plain C, I don’t really understand C++/# code when reading it, although I have certain mastery of the Lua language in case that helps.

So far I’ve been coding combining Lua for dictionary searches and designing data (and some logic parts) and left all video and audio storage, heavy math and “world” storage in C (using grid structures and a not-too-bruteforced collision detection approach (using a linear array to place objects in 1/24 of the map, nothing complex in code terms)). Because I could always rely on Lua’s solid code for some functions, I neglected learning more of C and now I am paying for it with lack of knowledge.

So, to formulate a question: “What is the basic use case for data trees?” The only idea I have so far is using a splay tree to match strings (filenames?) to textures. Is that a valid use? Should I begin with that?

  • 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-05-24T08:06:20+00:00Added an answer on May 24, 2026 at 8:06 am

    One of the uses for data trees was when writing a parser / compiler. After breaking up the source (Lexical analysis) and running the parsing (verifying grammar), we would build a tree structure of the source code (Syntactic tree), which was then repeatedly visited by the next parts of the compiler.

    Another use of trees is when having to match if strings belong to a set of words very quickly, using very little memory, you can use a DAWG (Directed acyclic word graph).

    Finally, a classic use is writing a solver for a Travelling Salesman problem using a data tree to store your cities in memory.

    The classic Sedgewick Algorithms in C, Part 5: Graph Algorithms is full of examples, also if you have access to it.

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

Sidebar

Related Questions

A recent question came up about using String.Format(). Part of my answer included a
This recent question about sorting randomly using C# got me thinking about the way
A recent question about string literals in .NET caught my eye. I know that
A recent question about StyleCop alerted me to the use of tools to enforce
Following on from my recent question on Large, Complex Objects as a Web Service
In a recent question on stubbing, many answers suggested C# interfaces or delegates for
Following on from my recent question regarding parsing XML files in Java I have
As just stated in a recent question and answer , you can't inherit from
In this answer to a recent question , I was advised to be wary
There is another recent Project Euler question but I think this is a bit

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.