Member Avatar

im trying to figure out why we are using binary computers insted of ternary. from what i can tell the only valid argument is the cost of storage. basicly for those of you who dont know that a ternary computer is, its a computer that uses three positions of the digital wave form as imputs so yo have +1 0 -1 interperated as 1 0 2 insted the the normal +1 -1 being interperated as 1 0. acording to my research there are existing storage mediums that are capable of storing 3 positions but they just cost more. i also …

Member Avatar
+0 forum 5 9
Member Avatar

For an array of n int variables, When does binary search perform better than ternary search?? Also, reverse case, ie when does ternary search perform better than binary search? Why is binary search a more preferred method of searching for integers entered in an array??

Member Avatar
+0 forum 12 15
Member Avatar

A Ternary Tree (T) is a tree in which every non terminal node has at most 3 children. We will use T to simulate the following activity: A set of P candidates must pass a set of exams ordered in an array of N exam codes (an exam code is an array of char). For a given exam, a candidate can be in one of the 3 following cases: success, failure or non-passed exam yet. Thus, every T node represents an exam with: exam code as root, succeeded candidates as left child, failed candidates as right child and in the …

Member Avatar
+0 forum 22 25
Member Avatar
Reusable Code Snippet Balanced ternary numbers

Here is my take on [balanced ternary](http://en.wikipedia.org/wiki/Balanced_ternary) conversion (the base considered by [Donald Knuth](http://en.wikipedia.org/wiki/Donald_Knuth) "Maybe the prettiest")

+1 forum 0 3
Member Avatar

Here is base conversion function written to deal also with [negative bases](http://en.wikipedia.org/wiki/Negative_base). Not yet balanced ternary, where numbers themselves can be negative, maybe later I add it.. Based on the code in the wikipedia article, which has bug for converting 0.[**Edit: I fixed the bug in wikipedia**]

Member Avatar
+0 forum 2 4
Member Avatar

I'm wondering if there is a way to simplify this program. I feel like I wasted a lot of time on all the ternary codes at the bottom for labeling "bill" for the three values (ten$, five$, and one$). Also for deriving the values for q,d,n, and p I feel like I was being redundant for no reason. -_- [CODE]/*This project will prompt for a valid double value for cash and determine the fewest number of bills and coins needed to reflect this value.*/ import java.util.Scanner; import java.text.DecimalFormat; public class Project9 { public static void main (String[]args) { int ten$,five$,one$,q,d,n,p; …

Member Avatar
+0 forum 3 4
Member Avatar

In C++ I'm able to do something like this [CODE](some_condition)? function1():function2();[/CODE] When i tried the same thing in Java it's not possible. It wants some variable to hold the result even though the return type of function1 and function2 are void. Is there any other way to do it other than if... else...?

Member Avatar
+0 forum 2 4
Member Avatar

Do you know that there is clean way of doing what C-language ternary operator ? does in Python's recent versions. It is if with special twist. The syntax is: [CODE]'The value if true' if <condition> else 'Value when false'[/CODE] Values can be any type. You can put this structure to replace single value. In this classic number guess game version we practise using the structure even in a nested way. This is not maybe so advisable general way, as it is less clear than many print statements in normal if statement. Anyway, this came first to my mind as demonstration …

+0 forum 0 16

The End.