background preloader

Language agnostic - What are the lesser known but useful data structures

Language agnostic - What are the lesser known but useful data structures

Programming, Software, and Technical Interview Questions - XOR Swap data structures - Deque implementation in Ruby current community your communities Sign up or log in to customize your list. more stack exchange communities Stack Exchange sign up log in tour help Code Review beta Ask Question Take the 2-minute tour × Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Deque implementation in Ruby 2 Answers active oldest votes Your Answer Sign up or log in Sign up using Google Sign up using Facebook Sign up using Stack Exchange Post as a guest discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Blog Editing is essential: new badges and review enhancements Related Ruby implementation of Soundex algorithm Read-write lock implementation for Ruby Concurrent stack implementations in Ruby (relative performance of mutexes/CAS?) Ruby implementation of Conway's Game of Life Ruby Branch and Bound Algorithm implementation? What is this structure called? A Ruby implementation of derangement (secret santa) algorithm question feed

Algo Muse 16-1 In the box There are n identical boxes in which 2n balls are equally distributed. The balls are labelled from 1 to 2n. We don't know which ball is in which box, but do know that each box contains two balls. The objective is to learn the arrangement of balls. For any set of balls S ⊆ {1,...,2n} we can ask a query of the form `How many boxes contain the balls in S?'. Prove that we can learn the distribution of balls by asking O(n log n) queries. Note that we cannot tell which ball is in which box. Solution Solution There are n pairs of balls. Lemma. Proof. How many boxes contain the balls in set A? If answers to both the questions are same, then x is paired with one of the balls in set A; else x is paired with one of the balls in set B. 16-2 Evasive Tree We prove the lower bound for the special case when the tree is a path, using an adversarial argument. Assume that the algorithm never asks a query to which it can infer the answer. Analysis. 16-3 Saving a log

Double-ended queue Naming conventions[edit] Distinctions and sub-types[edit] This differs from the queue abstract data type or First-In-First-Out List (FIFO), where elements can only be added to one end and removed from the other. An input-restricted deque is one where deletion can be made from both ends, but insertion can be made at one end only.An output-restricted deque is one where insertion can be made at both ends, but deletion can be made from one end only. Operations[edit] Names vary between languages; major implementations include: Implementations[edit] There are at least two common ways to efficiently implement a deque: with a modified dynamic array or with a doubly linked list. The dynamic array approach uses a variant of a dynamic array that can grow from both ends, sometimes called array deques. Storing deque contents in a circular buffer, and only resizing when the buffer becomes full. Language support[edit] Python 2.4 introduced the collections module with support for deque objects. See also[edit]

GeeksforGeeks Interview Questions | MyCareerStack A group of N high school students wants to play a basketball game. To divide themselves into two teams they first rank all the players in the following way: Players with a higher shot percentage are rated higher than players with a lower shot percentage. Luckily there are no two players with both the same shot percentage and height so they are able to order themselves in an unambiguous way. Each team can only have P players playing at a time, so to ensure that everyone gets similar time on the court both teams will rotate their players according to the following algorithm: Each team starts the game with the P players who have the lowest draft numbers. The game has been going on for M minutes now. Input The first line of the input consists of a single number T, the number of test cases. Each test case starts with a line containing three space separated integers N M P The subsequent N lines are in the format " ". Constraints 1 ? Output Example

Practice and Learn - Google Code Jam On this page you can see results and code from past rounds of Google Code Jam, and you can try the problems for yourself. If you're new to Code Jam, try following the Quick-Start Guide. Where should I start? If you're new to programming contests, we highly recommend starting with the least difficult problems and moving up from there as you get more confident. Beware: the round that has the easiest problem A may have a very difficult problem B! Here are some choice problems for new competitors: Africa 2010, Qualification Round: Store Credit, Reverse Words. Remember, if you get stuck you can look at someone else's solution (click a "solutions" link below) or join our mailing list and ask for help. Finding Solutions You can click a "solutions" link below, but those aren't really indexed in a helpful way. Finding Inputs and Outputs You can click the link to a contest name below and download the inputs for each problem, but the correct outputs for those inputs are not provided. TopCoder

Sphere Online Judge (SPOJ) Using Uninitialized Memory for Fun and Profit This is the story of a clever trick that's been around for at least 35 years, in which array values can be left uninitialized and then read during normal operations, yet the code behaves correctly no matter what garbage is sitting in the array. Like the best programming tricks, this one is the right tool for the job in certain situations. The sleaziness of uninitialized data access is offset by performance improvements: some important operations change from linear to constant time. Alfred Aho, John Hopcroft, and Jeffrey Ullman's 1974 book The Design and Analysis of Computer Algorithms hints at the trick in an exercise (Chapter 2, exercise 2.12): Develop a technique to initialize an entry of a matrix to zero the first time it is accessed, thereby eliminating the O(||V||2) time to initialize an adjacency matrix. Jon Bentley's 1986 book Programming Pearls expands on the exercise (Column 1, exercise 8; exercise 9 in the Second Edition): add-member(i): dense[n] = i sparse[i] = n n++

List of data structures List of data structures From Wikipedia, the free encyclopedia Jump to: navigation, search This is a list of data structures. Contents [hide] Data types[edit] Primitive types[edit] Composite types[edit] (Sometimes also referred to as Plain old data structures.) Abstract data types[edit] Some properties of abstract data types: "Stable" means that input order is retained. Other structures such as "linked list" and "stack" cannot easily be defined this way because there are specific operations associated with them. Linear data structures[edit] Arrays[edit] Lists[edit] Trees[edit] Binary trees[edit] B-trees[edit] Heaps[edit] Trees[edit] In these data structures each tree node compares a bit slice of key values. Multiway trees[edit] Space-partitioning trees[edit] These are data structures used for space partitioning or binary space partitioning. Application-specific trees[edit] Hashes[edit] Graphs[edit] Other[edit] Retrieved from " Categories: Navigation menu Personal tools Namespaces

Related: