You are given input as order of graph n (highest number of edges connected to a node), you have to find the number of vertices in a Fibonacci cube graph of order n.
Input : n = 3 Output : 5 Explanation : Fib(n + 2) = Fib(5) = 5 Input : n = 2 Output : 3
A Fibonacci Cube Graph is similar to hypercube graph, but with a fibonacci number of vertices. In fibonacci cube graph only 1 vertex has degree n rest all has degree less than n.
Fibonacci cube graph of order n has F(n + 2) vertices, where F(n) is a n-th fibonacci number,
Fibonacii series : 1, 1, 2, 3, 5, 8, 13, 21, 34……………….
For input n as order of graph, find the corresponding fibonacci number at the position n + 2.
where F(n) = F(n – 1) + F(n – 2)
Approach : Find the (n + 2)-th fibonacci number.
Below is the implementation of above approach :
Note that the above code can be optimized to work in O(Log n) using efficient implementations discussed in Program for Fibonacci numbers
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Convert the undirected graph into directed graph such that there is no path of length greater than 1
- Maximum number of edges that N-vertex graph can have such that graph is Triangle free | Mantel's Theorem
- Graph implementation using STL for competitive programming | Set 2 (Weighted graph)
- Detect cycle in the graph using degrees of nodes of graph
- Check if a M-th fibonacci number divides N-th fibonacci number
- Convert undirected connected graph to strongly connected directed graph
- Fibonacci Word
- K- Fibonacci series
- Fibonacci Coding
- Nth Even Fibonacci Number
- Even Fibonacci Numbers Sum
- Fibonacci modulo p
- GCD and Fibonacci Numbers
- Fibonacci Search
- Sum of Fibonacci Numbers
- Non Fibonacci Numbers
- Nth XOR Fibonacci number
- Fibonacci problem (Value of Fib(N)*Fib(N) - Fib(N-1) * Fib(N+1))
- Fibonacci Power
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.