![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
#1 | ||
|
![]() لو جالك السؤال دا Write a recursive method pow that takes two arguments (first is an integer base and second is another integer exponent) and returns the base raised to that exponent. Example: pow(2, 4) returns 16 طبعا هتقول لي سؤال بسيط جدا واجابتة كالتالي كود PHP:
طيب هل ممكن نقلل عدد مرات الريكرشن لاقل من كدة ؟؟ وكيف؟؟ في انتظار تفاعلكم
|
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
#2 |
|
![]()
write a method that uses recursion to find the binary
representation of an integer كود PHP:
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
#3 |
|
![]()
Suppose you buy a budget-priced pocket PC and discover that the chip inside
can’t do multiplication, only addition. You program your way out of this quandary by writing a recursive method, mult(), that performs multiplication of x and y by adding x to itself y times. Its arguments are x and y and its return value is the product of x and y. Write such a method and a main() program to call it. Does the addition take place when the method calls itself or when it returns? الكود : كود PHP:
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
#4 | |
|
![]() اقتباس:
طبعا لا احد يتفاعل ولا حتي بيقول جزاك الله خيرا عموما نبغي الاجر من الله ================= المثال السابق O(n) n = exponent ممكن نخلي الميثود o(log n) ولكن لنفهم اولا هذة الجزئية : 2 اس 6 تساوي 2 اس 2 اس 3 تساوي 4 اس 3 وهكذا ممكن نستغل النقطة دي في الميثود بتاعتنا كالتالي كود PHP:
التعديل الأخير تم بواسطة hossam_2530 ; 24-05-2014 الساعة 01:00 PM |
|
![]() |
![]() |
![]() |
![]() |
![]() |
مواقع النشر (المفضلة) |
أدوات الموضوع | |
انواع عرض الموضوع | |
|
|
![]() |
![]() |
![]() |